merge
authorunc0rr
Sat, 05 Nov 2011 09:38:07 +0300
changeset 6287 68db7625060d
parent 6277 627b5752733a (current diff)
parent 6286 835392304f81 (diff)
child 6288 fcc50b96d20a
merge
--- a/hedgewars/GSHandlers.inc	Sat Nov 05 09:37:17 2011 +0300
+++ b/hedgewars/GSHandlers.inc	Sat Nov 05 09:38:07 2011 +0300
@@ -1424,10 +1424,13 @@
         end;
 
     if b then
-        DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(
-                   Gear^.dY) * 7,
+    begin
+        DrawTunnel(HHGear^.X + Gear^.dX * cHHRadius,
+        HHGear^.Y + Gear^.dY * cHHRadius - _1 -
+        ((hwAbs(Gear^.dX) / (hwAbs(Gear^.dX) + hwAbs(Gear^.dY))) * _0_5 * 7),
         Gear^.dX, Gear^.dY,
-        cHHRadius * 5, cHHRadius * 2 + 7);
+        cHHStepTicks, cHHRadius * 2 + 7);
+    end;
 
     if (TurnTimeLeft = 0) or (Gear^.Timer = 0) or ((HHGear^.Message and gmAttack) <> 0) then
         begin
--- a/hedgewars/SDLh.pas	Sat Nov 05 09:37:17 2011 +0300
+++ b/hedgewars/SDLh.pas	Sat Nov 05 09:38:07 2011 +0300
@@ -107,6 +107,7 @@
     SDL_INIT_NOPARACHUTE = $00100000;
     SDL_INIT_EVERYTHING  = $0000FFFF;
 
+    SDL_ALLEVENTS        = $FFFFFFFF;
     SDL_APPINPUTFOCUS    = $02;
     SDL_BUTTON_WHEELUP   = 4;
     SDL_BUTTON_WHEELDOWN = 5;
@@ -136,9 +137,18 @@
     SDL_JOYHATMOTION      = $602;
     SDL_JOYBUTTONDOWN     = $603;
     SDL_JOYBUTTONUP       = $604;
-    //TODO: implement otheer event types
+    SDL_FINGERDOWN        = $700;
+    SDL_FINGERUP          = $701;
+    SDL_FINGERMOTION      = $702;
+    SDL_TOUCHBUTTONDOWN   = $703;
+    SDL_TOUCHBUTTONUP     = $704;
+    SDL_DOLLARGESTURE     = $800;
+    SDL_DOLLARRECORD      = $801;
+    SDL_MULTIGESTURE      = $802;
+    SDL_CLIPBOARDUPDATE   = $900;
     SDL_USEREVENT         = $8000;
     SDL_LASTEVENT         = $FFFF;
+    // no compatibility events $7000
 
     // SDL_Surface flags
     SDL_SWSURFACE   = $00000000;  //*< Not used */
@@ -228,8 +238,6 @@
     SDL_HWPALETTE   = $20000000;
     SDL_DOUBLEBUF   = $40000000;
     SDL_FULLSCREEN  = $80000000;
-
-    SDL_ALLEVENTS = $FFFFFFFF;
 {$ENDIF}
 
 {$IFDEF ENDIAN_LITTLE}
@@ -286,6 +294,10 @@
 ///////////////////////  TYPE DEFINITIONS ///////////////////////
 /////////////////////////////////////////////////////////////////
 
+// two important reference points for the wanderers of this area
+// http://www.freepascal.org/docs-html/ref/refsu5.html
+// http://www.freepascal.org/docs-html/prog/progsu144.html
+
 type
 {$IFDEF SDL13}
     PSDL_Window   = Pointer;
@@ -311,15 +323,15 @@
     PSDL_PixelFormat = ^TSDL_PixelFormat;
     TSDL_PixelFormat = record
 {$IFDEF SDL13}
-        format: Longword;
-        palette: Pointer;   // actually it is a PSDL_Palette
+        format: LongWord;
+        palette: Pointer;
         BitsPerPixel : Byte;
         BytesPerPixel: Byte;
         padding: array[0..1] of Byte;
-        RMask : Longword;
-        GMask : Longword;
-        BMask : Longword;
-        AMask : Longword;
+        RMask : LongWord;
+        GMask : LongWord;
+        BMask : LongWord;
+        AMask : LongWord;
         Rloss : Byte;
         Gloss : Byte;
         Bloss : Byte;
@@ -342,11 +354,11 @@
         Gshift: Byte;
         Bshift: Byte;
         Ashift: Byte;
-        RMask : Longword;
-        GMask : Longword;
-        BMask : Longword;
-        AMask : Longword;
-        colorkey: Longword;
+        RMask : LongWord;
+        GMask : LongWord;
+        BMask : LongWord;
+        AMask : LongWord;
+        colorkey: LongWord;
         alpha: Byte;
 {$ENDIF}
         end;
@@ -355,10 +367,10 @@
 
     PSDL_Surface = ^TSDL_Surface;
     TSDL_Surface = record
-        flags : Longword;
+        flags : LongWord;
         format: PSDL_PixelFormat;
         w, h  : LongInt;
-        pitch : Word;
+        pitch : {$IFDEF SDL13}LongInt{$ELSE}Word{$ENDIF};
         pixels: Pointer;
         offset: LongInt;
 {$IFDEF SDL13}
@@ -374,12 +386,12 @@
 
     PSDL_Color = ^TSDL_Color;
     TSDL_Color = record
-        case byte of
+        case Byte of
             0: ( r: Byte;
                  g: Byte;
                  b: Byte;
                  unused: Byte; );
-            1: ( value: Longword; );
+            1: ( value: LongWord; );
         end;
 
 
@@ -390,8 +402,8 @@
     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
 
     TStdio = record
-        autoclose: {$IFDEF SDL13}boolean{$ELSE}LongInt{$ENDIF};
-        fp: pointer;
+        autoclose: {$IFDEF SDL13}Boolean{$ELSE}LongInt{$ENDIF};
+        fp: Pointer;
         end;
 
     TMem = record
@@ -409,7 +421,7 @@
         read: TRead;
         write: TWrite;
         close: TClose;
-        type_: Longword;
+        type_: LongWord;
         case Byte of
             0: (stdio: TStdio);
             1: (mem: TMem);
@@ -423,31 +435,84 @@
     TSDL_KeySym = record
         scancode: LongInt;
         sym: LongInt;
-        modifier: Smallint;
-        unicode: LongInt;
+        modifier: Word;
+        unicode: LongWord;
         end;
 
     TSDL_WindowEvent = record
-        type_: LongInt;
-        windowID: LongInt;
-        event: byte;
-        padding1, padding2, padding3: byte;
+        type_: LongWord;
+        windowID: LongWord;
+        event: Byte;
+        padding1, padding2, padding3: Byte;
         data1, data2: LongInt;
         end;
+
+    // available in sdl12 but not exposed
+    TSDL_TextEditingEvent = record
+        type_: LongWord;
+        windowID: LongWord;
+        text: array[0..31] of Byte;
+        start, lenght: LongInt;
+        end;
+
+    // available in sdl12 but not exposed
+    TSDL_TextInputEvent = record
+        type_: LongWord;
+        windowID: LongWord;
+        text: array[0..31] of Byte;
+        end;
+
+    TSDL_TouchFingerEvent = record
+        type_: LongWord;
+        windowId: LongWord;
+        touchId: Int64;
+        fingerId: Int64;
+        state, padding1, padding2, padding3: Byte;
+        x, y: Word;
+        dx, dy: SmallInt;
+        pressure: Word;
+        end;
+
+    TSDL_TouchButtonEvent = record
+        type_: LongWord;
+        windowId: LongWord;
+        touchId: Int64;
+        state, button, padding1, padding2: Byte;
+        end;
+
+    TSDL_MultiGestureEvent = record
+        type_: LongWord;
+        windowId: LongWord;
+        touchId: Int64;
+        dTheta, dDist, x, y: Single;
+        numFingers, padding: Word;
+        end;
+
+    TSDL_DollarGestureEvent = record
+        type_: LongWord;
+        windowId: LongWord;
+        touchId: Int64;
+        gesturedId: Int64;
+        numFingers: LongWord;
+        error: Single;
+        end;
+
+    TSDL_SysWMEvent = record
+        type_: LongWord;
+        msg: Pointer;
+        end;
 {$ELSE}
     TSDL_KeySym = record
         scancode: Byte;
-        sym: Longword;
-        modifier: Longword;
+        sym: LongWord;
+        modifier: LongWord;
         unicode: Word;
         end;
 
-    // these two are present in sdl1.3 but only for backward compatibility
-    // and in 1.3 type_ is LongInt, not byte
     TSDL_ActiveEvent = record
-        type_: byte;
-        gain: byte;
-        state: byte;
+        type_: Byte;
+        gain: Byte;
+        state: Byte;
         end;
 
     TSDL_ResizeEvent = record
@@ -458,88 +523,75 @@
 
     TSDL_KeyboardEvent = record
 {$IFDEF SDL13}
-        type_: LongInt;
-        windowID: LongInt;
-        state, repeat_, padding2, padding3: byte;
+        type_: LongWord;
+        windowID: LongWord;
+        state, repeat_, padding2, padding3: Byte;
 {$ELSE}
-        type_: byte;
-        which: byte;
-        state: byte;
+        type_, which, state: Byte;
 {$ENDIF}
         keysym: TSDL_KeySym;
         end;
 
-//TODO: implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
-
-    // this structure is wrong but the correct version makes the game hang
     TSDL_MouseMotionEvent = record
-        which: byte;
-        state: byte;
 {$IFDEF SDL13}
-        type_: LongInt;
-        windowID: LongInt;
-        padding1, padding2: byte;
+        type_: LongWord;
+        windowID: LongWord;
+        state, padding1, padding2, padding3: Byte;
         x, y, z, xrel, yrel : LongInt;
-        pressure, pressure_max, pressure_min,
-        rotation, tilt, cursor: LongInt;
 {$ELSE}
-        type_: byte;
-        x, y, xrel, yrel : word;
+        type_, which, state: Byte;
+        x, y, xrel, yrel : Word;
 {$ENDIF}
         end;
 
     TSDL_MouseButtonEvent = record
 {$IFDEF SDL13}
-        type_: LongInt;
-        windowID: LongInt;
+        type_: LongWord;
+        windowID: LongWord;
+        buttonm, state, padding1, padding2: Byte;
         x, y: LongInt;
-        padding1: byte;
 {$ELSE}
-        type_,
-        which,
-        button,
-        state: byte;
-        x, y: word;
+        type_, which, button, state: Byte;
+        x, y: Word;
 {$ENDIF}
         end;
 
+    TSDL_MouseWheelEvent = record
+        type_: LongWord;
 {$IFDEF SDL13}
-    TSDL_MouseWheelEvent = record
-        type_: LongInt;
-        windowID: LongInt;
+        windowID: LongWord;
+{$ELSE}
         which: Byte;
+{$ENDIF}
         x, y: LongInt;
         end;
 
-//TODO: implement SDL_ProximityEvent
-{$ENDIF}
-
     TSDL_JoyAxisEvent = record
-        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
+        type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
         which: Byte;
         axis: Byte;
 {$IFDEF SDL13}
         padding1, padding2: Byte;
         value: LongInt;
 {$ELSE}
-        value: Smallint;
+        value: SmallInt;
 {$ENDIF}
         end;
 
     TSDL_JoyBallEvent = record
-        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
+        type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
         which: Byte;
         ball: Byte;
 {$IFDEF SDL13}
         padding1, padding2: Byte;
         xrel, yrel: LongInt;
 {$ELSE}
-        xrel, yrel: Smallint;
+        xrel, yrel: SmallInt;
 {$ENDIF}
         end;
 
     TSDL_JoyHatEvent = record
-        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
+        type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
         which: Byte;
         hat: Byte;
         value: Byte;
@@ -549,7 +601,7 @@
         end;
 
     TSDL_JoyButtonEvent = record
-        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
+        type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
         which: Byte;
         button: Byte;
         state: Byte;
@@ -558,16 +610,14 @@
 {$ENDIF}
         end;
 
-//TODO: implement SDL_TouchButtonEvent, SDL_MultiGestureEvent, SDL_DollarGestureEvent
-
     TSDL_QuitEvent = record
-        type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
+        type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
         end;
 
     TSDL_UserEvent = record
 {$IFDEF SDL13}
-        type_: LongInt;
-        windowID: LongInt;
+        type_: LongWord;
+        windowID: LongWord;
 {$ELSE}
         type_: Byte;
 {$ENDIF}
@@ -583,8 +633,8 @@
             SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
             SDL_KEYDOWN,
             SDL_KEYUP: (key: TSDL_KeyboardEvent);
-            SDL_TEXTEDITING,
-            SDL_TEXTINPUT: (edit: byte);
+            SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
+            SDL_TEXTINPUT: (tedit: TSDL_TextInputEvent);
             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
             SDL_MOUSEBUTTONDOWN,
             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
@@ -596,10 +646,18 @@
             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
             SDL_QUITEV: (quit: TSDL_QuitEvent);
             SDL_USEREVENT: (user: TSDL_UserEvent);
-            //TODO: implement other events
+            SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
+            SDL_FINGERDOWN,
+            SDL_FINGERUP,
+            SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
+            SDL_TOUCHBUTTONUP,
+            SDL_TOUCHBUTTONDOWN: (tbutton: TSDL_TouchButtonEvent);
+            SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
+            SDL_DOLLARGESTURE: (dgesture: TSDL_DollarGestureEvent);
+            SDL_ALLEVENTS: (foo: shortstring);
 {$ELSE}
         case Byte of
-            SDL_NOEVENT: (type_: byte);
+            SDL_NOEVENT: (type_: Byte);
             SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
             SDL_KEYDOWN,
             SDL_KEYUP: (key: TSDL_KeyboardEvent);
@@ -614,6 +672,7 @@
             SDL_QUITEV: (quit: TSDL_QuitEvent);
             //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB
             SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
+            SDL_ALLEVENTS: (foo: shortstring);
 {$ENDIF}
         end;
 
@@ -654,7 +713,7 @@
         );
 
 {$IFDEF SDL13}
-    TSDL_ArrayByteOrder = (  // array component order, low byte -> high byte
+    TSDL_ArrayByteOrder = (  // array component order, low Byte -> high Byte
         SDL_ARRAYORDER_NONE,
         SDL_ARRAYORDER_RGB,
         SDL_ARRAYORDER_RGBA,
@@ -678,9 +737,9 @@
     {* SDL_mixer *}
     PMixChunk = ^TMixChunk;
     TMixChunk = record
-        allocated: Longword;
+        allocated: LongWord;
         abuf     : PByte;
-        alen     : Longword;
+        alen     : LongWord;
         volume   : PByte;
         end;
     TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3);
@@ -688,13 +747,13 @@
 
     TMidiSong = record
                samples : LongInt;
-               events  : pointer;
+               events  : Pointer;
                end;
 
     TMusicUnion = record
         case Byte of
              0: ( midi : TMidiSong );
-             1: ( ogg  : pointer);
+             1: ( ogg  : Pointer);
              end;
 
     PMixMusic = ^TMixMusic;
@@ -703,7 +762,7 @@
 
     {* SDL_net *}
     TIPAddress = record
-                  host: Longword;
+                  host: LongWord;
                   port: Word;
                   end;
 
@@ -729,16 +788,12 @@
 
 
 {* SDL *}
-function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
+function  SDL_Init(flags: LongWord): LongInt; cdecl; external SDLLibName;
 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
 procedure SDL_Quit; cdecl; external SDLLibName;
 
-function  SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName;
-function  SDL_EnableUNICODE(enable: LongInt): LongInt; cdecl; external SDLLibName;
-function  SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; cdecl; external SDLLibName;
-
-procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName;
-function  SDL_GetTicks: Longword; cdecl; external SDLLibName;
+procedure SDL_Delay(msec: LongWord); cdecl; external SDLLibName;
+function  SDL_GetTicks: LongWord; cdecl; external SDLLibName;
 
 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
@@ -746,23 +801,23 @@
 
 function  SDL_GetError: PChar; cdecl; external SDLLibName;
 
-function  SDL_SetVideoMode(width, height, bpp: LongInt; flags: Longword): PSDL_Surface; cdecl; external SDLLibName;
-function  SDL_CreateRGBSurface(flags: Longword; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName;
-function  SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName;
+function  SDL_SetVideoMode(width, height, bpp: LongInt; flags: LongWord): PSDL_Surface; cdecl; external SDLLibName;
+function  SDL_CreateRGBSurface(flags: LongWord; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: LongWord): PSDL_Surface; cdecl; external SDLLibName;
+function  SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: LongWord): PSDL_Surface; cdecl; external SDLLibName;
 procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName;
-function  SDL_SetColorKey(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName;
-function  SDL_SetAlpha(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName;
+function  SDL_SetColorKey(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName;
+function  SDL_SetAlpha(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName;
 function  SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: LongInt): PSDL_Surface; cdecl; external SDLLibName;
 
 function  SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
-function  SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: Longword): LongInt; cdecl; external SDLLibName;
-procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: Longword); cdecl; external SDLLibName;
+function  SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: LongWord): LongInt; cdecl; external SDLLibName;
+procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: LongWord); cdecl; external SDLLibName;
 function  SDL_Flip(Screen: PSDL_Surface): LongInt; cdecl; external SDLLibName;
 
-procedure SDL_GetRGB(pixel: Longword; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName;
-procedure SDL_GetRGBA(pixel: Longword; fmt: PSDL_PixelFormat; r, g, b, a: PByte); cdecl; external SDLLibName;
-function  SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): Longword; cdecl; external SDLLibName;
-function  SDL_MapRGBA(format: PSDL_PixelFormat; r, g, b, a: Byte): Longword; cdecl; external SDLLibName;
+procedure SDL_GetRGB(pixel: LongWord; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName;
+procedure SDL_GetRGBA(pixel: LongWord; fmt: PSDL_PixelFormat; r, g, b, a: PByte); cdecl; external SDLLibName;
+function  SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): LongWord; cdecl; external SDLLibName;
+function  SDL_MapRGBA(format: PSDL_PixelFormat; r, g, b, a: Byte): LongWord; cdecl; external SDLLibName;
 
 function  SDL_DisplayFormat(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
 function  SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
@@ -771,11 +826,12 @@
 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
 
 {$IFDEF SDL13}
-function  SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): PSDL_Window; cdecl; external SDLLibName;
-function  SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): PSDL_Renderer; cdecl; external SDLLibName;
+function  SDL_CreateWindow(title: PChar; x,y,w,h: LongInt; flags: LongWord): PSDL_Window; cdecl; external SDLLibName;
+function  SDL_CreateRenderer(window: PSDL_Window; index: LongInt; flags: LongWord): PSDL_Renderer; cdecl; external SDLLibName;
 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
+function  SDL_GetCurrentVideoDriver:Pchar; cdecl; external SDLLibName;
 
 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
@@ -786,38 +842,37 @@
 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
 procedure SDL_ShowWindow(window: PSDL_Window); cdecl; external SDLLibName;
 
-function  SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r,g,b,a: byte): LongInt; cdecl; external SDLLibName;
+function  SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r,g,b,a: Byte): LongInt; cdecl; external SDLLibName;
 function  SDL_GetRenderer(window: PSDL_Window): PSDL_Renderer; cdecl; external SDLLibName;
 function  SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
 function  SDL_RenderClear(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
 procedure SDL_RenderPresent(renderer: PSDL_Renderer); cdecl; external SDLLibName;
-function  SDL_RenderReadPixels(renderer: PSDL_Renderer; rect: PSDL_Rect; format: LongInt; pixels: pointer; pitch: LongInt): LongInt; cdecl; external SDLLibName;
+function  SDL_RenderReadPixels(renderer: PSDL_Renderer; rect: PSDL_Rect; format: LongInt; pixels: Pointer; pitch: LongInt): LongInt; cdecl; external SDLLibName;
 function  SDL_RenderSetViewport(window: PSDL_Window; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
 
-function  SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName;
 function  SDL_GetRelativeMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
-function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
-function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
+function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): Boolean; cdecl; external SDLLibName;
 
 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
-function  SDL_SetHint(name, value: PChar): boolean; cdecl; external SDLLibName;
+function  SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName;
+procedure SDL_StartTextInput; cdecl; external SDLLibName;
 
-function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongInt): LongInt; cdecl; external SDLLibName;
+function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName;
 {$ELSE}
-function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: Longword): LongInt; cdecl; external SDLLibName;
+function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName;
 {$ENDIF}
 
 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
-function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
+function  SDL_GetKeyName(key: LongWord): PChar; cdecl; external SDLLibName;
 
 procedure SDL_PumpEvents; cdecl; external SDLLibName;
 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
-procedure SDL_SetEventFilter( filter : TSDL_EventFilter ); cdecl; external SDLLibName;
+procedure SDL_SetEventFilter(filter: TSDL_EventFilter); cdecl; external SDLLibName;
 
 function  SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName;
 
-procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : byte); cdecl; external SDLLibName;
+procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : Byte); cdecl; external SDLLibName;
 procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName;
 function  SDL_WM_ToggleFullScreen(surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
 
@@ -854,14 +909,17 @@
 {* Compatibility between SDL-1.2 and SDL-1.3 *}
 procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
-function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
+function  SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
+function  SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
+function  SDL_EnableUNICODE(enable: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
+function  SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
 
 (*  SDL_ttf  *)
 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
 
-function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; out w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName;
+function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; w, h: PLongInt): LongInt; cdecl; external SDL_TTFLibName;
 
 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
 function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
@@ -927,13 +985,13 @@
 function  SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
 
 
-procedure SDLNet_Write16(value: Word; buf: pointer);
-procedure SDLNet_Write32(value: LongWord; buf: pointer);
-function  SDLNet_Read16(buf: pointer): Word;
-function  SDLNet_Read32(buf: pointer): LongWord;
+procedure SDLNet_Write16(value: Word; buf: Pointer);
+procedure SDLNet_Write32(value: LongWord; buf: Pointer);
+function  SDLNet_Read16(buf: Pointer): Word;
+function  SDLNet_Read32(buf: Pointer): LongWord;
 
 implementation
-uses uVariables;
+uses strings, uVariables;
 
 {$IFDEF SDL13}
 // this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode
@@ -942,8 +1000,31 @@
 begin
     SDL_WarpMouseInWindow(SDLwindow, x, y);
 end;
+
+function SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar;
+var name : PChar = nil;
+begin
+    name:= SDL_GetCurrentVideoDriver();
+    if (name <> nil) and (namebuf <> nil) then
+        begin
+        strlcopy(namebuf, name, maxlen);
+        exit(namebuf)
+        end;
+    exit(name);
+end;
+
+function SDL_EnableUNICODE(enable: LongInt): LongInt;
+begin
+    SDL_StartTextInput();
+    exit(0);
+end;
+
+function SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt;
+begin
+    exit(0);
+end;
 {$ELSE}
-function SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
+function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat;
 const conversionFormat: TSDL_PixelFormat = (
         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
@@ -993,13 +1074,13 @@
 end;
 {$ENDIF}
 
-procedure SDLNet_Write16(value: Word; buf: pointer);
+procedure SDLNet_Write16(value: Word; buf: Pointer);
 begin
     PByteArray(buf)^[1]:= value;
     PByteArray(buf)^[0]:= value shr 8
 end;
 
-procedure SDLNet_Write32(value: LongWord; buf: pointer);
+procedure SDLNet_Write32(value: LongWord; buf: Pointer);
 begin
     PByteArray(buf)^[3]:= value;
     PByteArray(buf)^[2]:= value shr  8;
@@ -1007,13 +1088,13 @@
     PByteArray(buf)^[0]:= value shr 24
 end;
 
-function SDLNet_Read16(buf: pointer): Word;
+function SDLNet_Read16(buf: Pointer): Word;
 begin
     SDLNet_Read16:= PByteArray(buf)^[1] or
                  (PByteArray(buf)^[0] shl 8)
 end;
 
-function SDLNet_Read32(buf: pointer): LongWord;
+function SDLNet_Read32(buf: Pointer): LongWord;
 begin
     SDLNet_Read32:=  PByteArray(buf)^[3] or
                   (PByteArray(buf)^[2] shl  8) or
--- a/hedgewars/uChat.pas	Sat Nov 05 09:37:17 2011 +0300
+++ b/hedgewars/uChat.pas	Sat Nov 05 09:38:07 2011 +0300
@@ -84,7 +84,7 @@
 
 font:= CheckCJKFont(str, fnt16);
 w:= 0; h:= 0; // avoid compiler hints
-TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), w, h);
+TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), @w, @h);
 
 resSurface:= SDL_CreateRGBSurface(0, toPowerOf2(w), toPowerOf2(h), 32, RMask, GMask, BMask, AMask);
 
--- a/hedgewars/uCollisions.pas	Sat Nov 05 09:37:17 2011 +0300
+++ b/hedgewars/uCollisions.pas	Sat Nov 05 09:38:07 2011 +0300
@@ -52,7 +52,8 @@
 
 function  TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
 
-function  CalcSlopeTangentBelowGear(Gear: PGear; var outDeltaX, outDeltaY: LongInt): boolean;
+// returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45° = _0_5)
+function  CalcSlopeBelowGear(Gear: PGear): hwFloat;
 function  CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean;
 
 implementation
@@ -403,7 +404,7 @@
     if (dx.QWordValue > _0_995.QWordValue )
     or (dy.QWordValue > _0_995.QWordValue ) then
         begin // scale
-        s := _1 / Distance(dx,dy);
+        s := _0_995 / Distance(dx,dy);
         dx := s * dx;
         dy := s * dy;
         end;
@@ -519,17 +520,12 @@
 exit(true);
 end;
 
-function CalcSlopeTangentBelowGear(Gear: PGear; var outDeltaX, outDeltaY: LongInt): boolean;
+function CalcSlopeBelowGear(Gear: PGear): hwFloat;
 var dx, dy: hwFloat;
-    collX, i, y, x, gx: LongInt;
+    collX, i, y, x, gx, sdx, sdy: LongInt;
     isColl, succ: Boolean;
 begin
-// save original dx/dy
-dx:= Gear^.dX;
-dy:= Gear^.dY;
 
-Gear^.dX.QWordValue:= 0;
-Gear^.dY:= _1;
 
 y:= hwRound(Gear^.Y) + Gear^.Radius;
 gx:= hwRound(Gear^.X);
@@ -553,15 +549,32 @@
    end;
 
 if isColl then
-    succ := CalcSlopeTangent(Gear, collX, y, outDeltaX, outDeltaY, 255)
-else
-    succ := false;
+    begin
+    // save original dx/dy
+    dx := Gear^.dX;
+    dy := Gear^.dY;
+
+    Gear^.dX.QWordValue:= 0;
+    Gear^.dX.isNegative:= (collX >= gx);
+    Gear^.dY:= _1;
+
+    sdx:= 0;
+    sdy:= 0;
+    succ := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 255);
 
-// restore original dx/dy
-Gear^.dX:= dx;
-Gear^.dY:= dy;
+    // restore original dx/dy
+    Gear^.dX := dx;
+    Gear^.dY := dy;
 
-CalcSlopeTangentBelowGear := succ;
+    if succ and (sdx <> 0) and (sdy <> 0) then
+    begin
+        dx := int2hwFloat(sdy) / (abs(sdx) + abs(sdy));
+        dx.isNegative := (sdx * sdy) < 0;
+        exit (dx);
+    end;
+    end;
+
+CalcSlopeBelowGear := _0;
 end;
 
 procedure initModule;
--- a/hedgewars/uRenderUtils.pas	Sat Nov 05 09:37:17 2011 +0300
+++ b/hedgewars/uRenderUtils.pas	Sat Nov 05 09:38:07 2011 +0300
@@ -68,7 +68,7 @@
     clr: TSDL_Color;
     finalRect: TSDL_Rect;
 begin
-    TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), w, h);
+    TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h);
     finalRect.x:= X;
     finalRect.y:= Y;
     finalRect.w:= w + FontBorder * 2 + 4;
@@ -173,7 +173,7 @@
     if length(s) = 0 then s:= ' ';
     font:= CheckCJKFont(s, font);
     w:= 0; h:= 0; // avoid compiler hints
-    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), w, h);
+    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
 
     finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + FontBorder * 2 + 4, h + FontBorder * 2,
             32, RMask, GMask, BMask, AMask);
@@ -229,7 +229,7 @@
     if length(s) = 0 then s:= '...';
     font:= CheckCJKFont(s, font);
     w:= 0; h:= 0; // avoid compiler hints
-    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), w, h);
+    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
     if w<8 then w:= 8;
     j:= 0;
     if (length(s) > 20) then
@@ -248,7 +248,7 @@
                 while s[prevpos+1] = ' ' do inc(prevpos);
                 substr:= copy(s, prevpos+1, pos-prevpos-1);
                 i:= 0; j:= 0;
-                TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(substr), i, j);
+                TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(substr), @i, @j);
                 if i > w then w:= i;
                 prevpos:= pos;
                 end;
--- a/hedgewars/uStore.pas	Sat Nov 05 09:37:17 2011 +0300
+++ b/hedgewars/uStore.pas	Sat Nov 05 09:38:07 2011 +0300
@@ -56,7 +56,7 @@
     finalRect: TSDL_Rect;
 begin
 w:= 0; h:= 0; // avoid compiler hints
-TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), w, h);
+TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h);
 finalRect.x:= X + FontBorder + 2;
 finalRect.y:= Y + FontBorder;
 finalRect.w:= w + FontBorder * 2 + 4;
@@ -796,13 +796,13 @@
 // TODO: Recheck height/position calculation
 
 // get caption's dimensions
-TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(caption), i, j);
+TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(caption), @i, @j);
 // width adds 36 px (image + space)
 w:= i + 36 + wa;
 h:= j + ha;
 
 // get sub caption's dimensions
-TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(subcaption), i, j);
+TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(subcaption), @i, @j);
 // width adds 36 px (image + space)
 if w < (i + 36 + wa) then w:= i + 36 + wa;
 inc(h, j + ha);
@@ -815,7 +815,7 @@
     SplitByChar(tmpline, tmpdesc, '|');
     if tmpline <> '' then
         begin
-        TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(tmpline), i, j);
+        TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(tmpline), @i, @j);
         if w < (i + wa) then w:= i + wa;
         inc(h, j + ha)
         end
@@ -824,7 +824,7 @@
 if extra <> '' then
     begin
     // get extra label's dimensions
-    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), i, j);
+    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), @i, @j);
     if w < (i + wa) then w:= i + wa;
     inc(h, j + ha);
     end;
--- a/hedgewars/uWorld.pas	Sat Nov 05 09:37:17 2011 +0300
+++ b/hedgewars/uWorld.pas	Sat Nov 05 09:38:07 2011 +0300
@@ -185,8 +185,16 @@
 WorldDy:=  - (LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
 AMSlotSize:= 33;
 {$IFDEF IPHONEOS}
-AMxOffset:= 10;
-AMyOffset:= 10 + 123;   // moved downwards
+if isPhone() then
+    begin
+    AMxOffset:= -30 + cScreenHeight div 2;
+    AMyOffset:= 10;
+    end
+else
+    begin
+    AMxOffset:= AMSlotSize + cScreenHeight div 2;
+    AMyOffset:= -10 + cScreenWidth div 3;
+    end;
 AMWidth:= (cMaxSlotAmmoIndex + 1) * AMSlotSize + AMxOffset;
 {$ELSE}
 AMxOffset:= 10;
@@ -210,205 +218,206 @@
     Slot, Pos, STurns: LongInt;
     Ammo: PHHAmmo;
 begin
-if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
-    bShowAmmoMenu:= false;
-if bShowAmmoMenu then
-   begin
-   FollowGear:= nil;
-   if AMxShift = AMWidth then prevPoint.X:= 0;
-   if (cReducedQuality and rqSlowMenu) <> 0 then
-       AMxShift:= 0
-   else
-       if AMxShift > MENUSPEED then
-           dec(AMxShift, MENUSPEED)
-       else
-           AMxShift:= 0;
-   end else
-   begin
-   if AMxShift = 0 then
-      begin
-      CursorPoint.X:= cScreenWidth shr 1;
-      CursorPoint.Y:= cScreenHeight shr 1;
-      prevPoint:= CursorPoint;
-      end;
-   if (cReducedQuality and rqSlowMenu) <> 0 then
-       AMxShift:= AMWidth
-   else
-       if AMxShift < (AMWidth - MENUSPEED) then
-           inc(AMxShift, MENUSPEED)
-       else
-           AMxShift:= AMWidth;
-   end;
-Ammo:= nil;
-if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
-   Ammo:= CurrentHedgehog^.Ammo
-else if (LocalAmmo <> -1) then
-   Ammo:= GetAmmoByNum(LocalAmmo);
-Pos:= -1;
-if Ammo = nil then
-    begin
-    bShowAmmoMenu:= false;
-    exit
-    end;
-SlotsNum:= 0;
-x:= (cScreenWidth shr 1) - AMWidth + AMxShift;
+    if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or
+       ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
+        bShowAmmoMenu:= false;
 
-{$IFDEF IPHONEOS}
-Slot:= cMaxSlotIndex;
-x:= x - cOffsetY;
-y:= AMyOffset;
-dec(y, BORDERSIZE);
-DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
-for i:= 0 to cMaxSlotAmmoIndex do
-    DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
-DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
-inc(y, BORDERSIZE);
-
-for i:= 0 to cMaxSlotIndex do
-    if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
+    if bShowAmmoMenu then
+    // show ammo menu
         begin
-        if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then Slot:= i;
-        inc(SlotsNum);
-        DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
-        t:= 0;
-        g:= 0;
-        while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
+        FollowGear:= nil;
+        if AMxShift = AMWidth then prevPoint.X:= 0;
+        if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= 0
+        else
+            if AMxShift > MENUSPEED then dec(AMxShift, MENUSPEED)
+            else AMxShift:= 0;
+        end
+    else
+    // hide ammo menu
+        begin
+        if AMxShift = 0 then
             begin
-            DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
-            if (Ammo^[i, t].AmmoType <> amNothing) then
-                begin
-                STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
-
-                if STurns >= 0 then
-                    begin
-                    DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
-                    if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
-                    end else
-                    DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
-                if (Slot = i)
-                and (CursorPoint.X >= x + g * AMSlotSize)
-                and (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
-                    begin
-                    if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
-                    Pos:= t;
-                    end;
-                inc(g)
-                end;
-                inc(t)
+            CursorPoint.X:= cScreenWidth shr 1;
+            CursorPoint.Y:= cScreenHeight shr 1;
+            prevPoint:= CursorPoint;
             end;
-        for g:= g to cMaxSlotAmmoIndex do
-            DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
-        DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
-        inc(y, AMSlotSize);
+        if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= AMWidth+2
+        else
+            if AMxShift < (AMWidth - MENUSPEED) then inc(AMxShift, MENUSPEED)
+            else AMxShift:= AMWidth;
         end;
 
-DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
-for i:= 0 to cMaxSlotAmmoIndex do
-	DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
-DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
-{$ELSE}
-Slot:= 0;
-y:= cScreenHeight - AMyOffset;
-DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
-for i:= 0 to cMaxSlotAmmoIndex + 1 do
-    DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
-DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
-dec(y, AMSlotSize);
-DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
-for i:= 0 to cMaxSlotAmmoIndex do
-    DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
-DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1);
-DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
+    // give the assigned ammo to hedgehog
+    Ammo:= nil;
+    if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and
+       (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
+        Ammo:= CurrentHedgehog^.Ammo
+    else if (LocalAmmo <> -1) then
+        Ammo:= GetAmmoByNum(LocalAmmo);
+    Pos:= -1;
+    if Ammo = nil then
+        begin
+        bShowAmmoMenu:= false;
+        exit
+        end;
+    SlotsNum:= 0;
+    x:= (cScreenWidth shr 1) - AMWidth + AMxShift;
 
-for i:= cMaxSlotIndex downto 0 do
-    if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
-        begin
-        if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then Slot:= i;
-        dec(y, AMSlotSize);
-        inc(SlotsNum);
-        DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
-        DrawSprite(sprAMSlot, x, y, 1);
-        DrawSprite(sprAMSlotKeys, x, y + 1, i);
-        t:= 0;
-        g:= 1;
-        while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
+{$IFDEF IPHONEOS}
+    Slot:= cMaxSlotIndex;
+    x:= x - cOffsetY;
+    y:= AMyOffset;
+    dec(y, BORDERSIZE);
+    DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
+    for i:= 0 to cMaxSlotAmmoIndex do
+        DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
+    DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
+    inc(y, BORDERSIZE);
+
+    for i:= 0 to cMaxSlotIndex do
+        if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
             begin
-            DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
-            if (Ammo^[i, t].AmmoType <> amNothing) then
+            if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then Slot:= i;
+            inc(SlotsNum);
+            DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
+            t:= 0;
+            g:= 0;
+            while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
                 begin
-                STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
-
-                if STurns >= 0 then
-                    begin
-                    DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
-                    if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
-                    end else
-                    DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
-                if (Slot = i)
-                and (CursorPoint.X >= x + g * AMSlotSize)
-                and (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
+                DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
+                if (Ammo^[i, t].AmmoType <> amNothing) then
                     begin
-                    if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
-                    Pos:= t;
+                    STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
+
+                    if STurns >= 0 then
+                        begin
+                        DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
+                        if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
+                        end
+                    else
+                        DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
+                    if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and
+                       (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
+                        begin
+                        if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
+                        Pos:= t;
+                        end;
+                    inc(g)
                     end;
-                inc(g)
+                inc(t)
                 end;
-                inc(t)
+            for g:= g to cMaxSlotAmmoIndex do
+                DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
+            DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
+            inc(y, AMSlotSize);
             end;
-        for g:= g to cMaxSlotAmmoIndex + 1 do
-            DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
-        DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
-        end;
+
+    DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
+    for i:= 0 to cMaxSlotAmmoIndex do
+	DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
+    DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
+{$ELSE}
+    Slot:= 0;
+    y:= cScreenHeight - AMyOffset;
+    DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
+    for i:= 0 to cMaxSlotAmmoIndex + 1 do
+        DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
+    DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
+    dec(y, AMSlotSize);
+    DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
+    for i:= 0 to cMaxSlotAmmoIndex do
+        DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
+    DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1);
+    DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
 
-dec(y, BORDERSIZE);
-DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
-for i:= 0 to cMaxSlotAmmoIndex + 1 do
-    DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
-DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
+    for i:= cMaxSlotIndex downto 0 do
+        if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
+            begin
+            if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then Slot:= i;
+            dec(y, AMSlotSize);
+            inc(SlotsNum);
+            DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
+            DrawSprite(sprAMSlot, x, y, 1);
+            DrawSprite(sprAMSlotKeys, x, y + 1, i);
+            t:= 0;
+            g:= 1;
+            while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
+                begin
+                DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
+                if (Ammo^[i, t].AmmoType <> amNothing) then
+                    begin
+                    STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
+
+                    if STurns >= 0 then
+                        begin
+                        DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
+                        if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
+                        end else
+                        DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
+                    if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and
+                       (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
+                        begin
+                        if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
+                        Pos:= t;
+                        end;
+                    inc(g)
+                    end;
+                    inc(t)
+                end;
+            for g:= g to cMaxSlotAmmoIndex + 1 do
+                DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
+            DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
+            end;
+
+    dec(y, BORDERSIZE);
+    DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
+    for i:= 0 to cMaxSlotAmmoIndex + 1 do
+        DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
+    DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
 {$ENDIF}
 
-if (Pos >= 0) then
-    begin
-    if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
+    if (Pos >= 0) then
         begin
-        if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
+        if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
             begin
-            amSel:= Ammo^[Slot, Pos].AmmoType;
-            RenderWeaponTooltip(amSel)
-            end;
+            if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
+                begin
+                amSel:= Ammo^[Slot, Pos].AmmoType;
+                RenderWeaponTooltip(amSel)
+                end;
 
 {$IFDEF IPHONEOS}
-        DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
-
-        if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
-            DrawTexture(cScreenWidth div 2 + AMxOffset - 45, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
+            DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
+            if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
+                DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + 163, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
 {$ELSE}
-        DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
-        if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
-            DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
+            DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
+            if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
+                DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
 {$ENDIF}
 
-        if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
-            begin
-            bShowAmmoMenu:= false;
-            SetWeapon(Ammo^[Slot, Pos].AmmoType);
-            bSelected:= false;
-            FreeWeaponTooltip;
-            exit
-            end;
-       end
-    end
-else
-    FreeWeaponTooltip;
-if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
+            if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
+                begin
+                bShowAmmoMenu:= false;
+                SetWeapon(Ammo^[Slot, Pos].AmmoType);
+                bSelected:= false;
+                FreeWeaponTooltip;
+                exit
+                end;
+            end
+        end
+    else
+        FreeWeaponTooltip;
+
+    if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
 {$IFDEF IPHONEOS}
-    ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, AMyOffset - 1);
+        ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, 100);
 {$ELSE}
-    ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
+        ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
 {$ENDIF}
 
-bSelected:= false;
-if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
+    bSelected:= false;
+    if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
 end;
 
 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sat Nov 05 09:37:17 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sat Nov 05 09:38:07 2011 +0300
@@ -62,6 +62,8 @@
     else                                                                                                        // = everything else
         tmpQuality = 0;                                                                 // full quality
 
+    // disable ammomenu animation
+    tmpQuality = tmpQuality | 0x00000080;
     // disable tooltips on iPhone
     if (IS_IPAD() == NO)
         tmpQuality = tmpQuality | 0x00000400;
--- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Sat Nov 05 09:37:17 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Sat Nov 05 09:38:07 2011 +0300
@@ -239,9 +239,6 @@
                     cell.detailTextLabel.text = NSLocalizedString(@"Select which style of ammo menu you prefer",@"");
                     switchContent.on = [[settings objectForKey:@"classic_menu"] boolValue];
                     switchContent.tag = 60;
-                    // remove this when classic ammomenu works on iphone as well
-                    if (IS_IPAD() == NO)
-                        switchContent.enabled = NO;
                     break;
                 default:
                     DLog(@"Nope");