smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
authorkoda
Sun, 03 Jan 2010 15:40:41 +0000
changeset 2671 7e0f88013fe8
parent 2670 1b327b7515ed
child 2672 0f1403bf267a
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
CMakeLists.txt
hedgewars/CCHandlers.inc
hedgewars/CMakeLists.txt
hedgewars/SDLh.pas
hedgewars/getdocumentpath.m
hedgewars/hwengine.pas
hedgewars/uConsts.pas
hedgewars/uKeys.pas
hedgewars/uLandObjects.pas
hedgewars/uLandTemplates.pas
hedgewars/uMisc.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
hedgewars/uVisualGears.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Themes/Island/Sky-lowres.png
--- a/CMakeLists.txt	Thu Dec 24 13:38:20 2009 +0000
+++ b/CMakeLists.txt	Sun Jan 03 15:40:41 2010 +0000
@@ -65,7 +65,7 @@
 		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${minimum_macosx}.sdk/")
 	endif()
 
-	set(pascal_compiler_flags_cmn "-k${PROJECT_BINARY_DIR}/bin/libSDLmain.a" "-k-macosx_version_min" "-k${minimum_macosx}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_compiler_flags_cmn})
+	set(pascal_compiler_flags_cmn "-k${CMAKE_BINARY_DIR}/bin/libSDLmain.a" "-k-macosx_version_min" "-k${minimum_macosx}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_compiler_flags_cmn})
 	
 else(APPLE)
 	set(target_dir "bin")
@@ -106,9 +106,9 @@
 
 if(Optz)
 	set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
-	set(haskell_compiler_flags_cmn "-w" "-O2")
+	set(haskell_compiler_flags_cmn "-O2" "-w")
 else(Optz)
-	set(pascal_compiler_flags_cmn "-O-" "-gl" "-dDEBUGFILE" "-pg" "-vv" ${pascal_compiler_flags_cmn})
+	set(pascal_compiler_flags_cmn "-O-" "-gh" "-gl" "-dDEBUGFILE" "-pg" "-vv" ${pascal_compiler_flags_cmn})
 	set(haskell_compiler_flags_cmn "-Wall" "-debug" "-dcore-lint")
 endif(Optz)
 
--- a/hedgewars/CCHandlers.inc	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/CCHandlers.inc	Sun Jan 03 15:40:41 2010 +0000
@@ -81,7 +81,7 @@
    val(s, Color);
    TryDo(Color <> 0, 'Error: black team color', true);
 
-   // color is always in ARGB so the mask must be constant
+   // color is always little endian so the mask must be constant also in big endian archs
    Color:= Color or $FF000000;
  	
    AddTeam(Color);
@@ -594,13 +594,13 @@
 end;
 
 procedure chFullScr(var s: shortstring);
-var flags: Longword;
+var flags: Longword = 0;
 {$IFDEF DEBUGFILE}
     buf: array[byte] of char;
 {$ENDIF}
 begin
 if Length(s) = 0 then cFullScreen:= not cFullScreen
-                 else cFullScreen:= s = '1';
+	else cFullScreen:= s = '1';
 
 {$IFDEF DEBUGFILE}
 AddFileLog('Prepare to change video parameters...');
@@ -620,11 +620,19 @@
 {$ENDIF}
 
 {$IFNDEF SDL13}
-// this attribute is default in 1.3
-SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
+// this attribute is default in 1.3 and must be enabled in MacOSX
+{$IFNDEF DARWIN}
+if cVSyncInUse then
+{$ENDIF}
+	SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
 {$ENDIF}
 
 flags:= SDL_OPENGL;// or SDL_RESIZABLE;
+{$IFDEF IPHONEOS}
+// remove the topbar from the iPhone
+flags:= flags or SDL_NOFRAME;
+{$ENDIF}
+
 if cFullScreen then
 	begin
 	flags:= flags or SDL_FULLSCREEN;
@@ -641,23 +649,16 @@
 	SDL_FreeSurface(SDLPrimSurface);
 	end;
 
-{$IFDEF IPHONEOS}
-//remove the topbar from the iPhone
-flags:= flags or SDL_NOFRAME;
-{$ENDIF}
-
 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
 SDLTry(SDLPrimSurface <> nil, true);
+PixelFormat:= SDLPrimSurface^.format;
 
 {$IFDEF DEBUGFILE}
 AddFileLog('Setting up OpenGL...');
+AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf))));
 {$ENDIF}
 SetupOpenGL();
 
-{$IFDEF DEBUGFILE}
-AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf))));
-{$ENDIF}
-PixelFormat:= SDLPrimSurface^.format
 end;
 
 procedure chVol_p(var s: shortstring);
--- a/hedgewars/CMakeLists.txt	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/CMakeLists.txt	Sun Jan 03 15:40:41 2010 +0000
@@ -90,7 +90,7 @@
 	string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
 	string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
 	string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
-	message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}.${fpc_vers_patch}")
+	message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}")
 	math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
 
 	if(fpc_ver LESS "020200")
@@ -120,7 +120,7 @@
 	find_package(SDL REQUIRED)
 
 	set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")	
-	set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+	set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
 	include_directories(${SDL_INCLUDE_DIR})
 
 	add_library (SDLmain STATIC SDLMain.m)
--- a/hedgewars/SDLh.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/SDLh.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *)
 
-{$INCLUDE "options.inc"}
+{$I "options.inc"}
 
 unit SDLh;
 interface
@@ -177,7 +177,11 @@
 
 	{* SDL_mixer *}
 	MIX_MAX_VOLUME = 128;
-
+	MIX_INIT_FLAC = $00000001;
+	MIX_INIT_MOD  = $00000002;
+	MIX_INIT_MP3  = $00000004;
+	MIX_INIT_OGG  = $00000008;
+	
 	{* SDL_TTF *}
 	TTF_STYLE_NORMAL = 0;
 	TTF_STYLE_BOLD   = 1;
@@ -568,6 +572,7 @@
 {* SDL *}
 function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
 procedure SDL_Quit; cdecl; external SDLLibName;
+
 function  SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName;
 procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName;
 
@@ -605,15 +610,14 @@
 
 {$IFDEF SDL13}
 function  SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
-function  SDL_GetMouseState(index: LongInt; x, y: PLongInt): Byte; cdecl; external SDLLibName;
 function  SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName;
 function  SDL_GetRelativeMouseState(index: LongInt; 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;
 {$ELSE}
 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
+{$ENDIF}
 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
-{$ENDIF}
 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
 procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
 
@@ -660,6 +664,7 @@
 (*  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; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName;
 
 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
@@ -670,6 +675,9 @@
 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
 
 (*  SDL_mixer  *)
+function  Mix_Init(flags: LongInt): LongInt; cdecl; external SDL_MixerLibName;
+procedure Mix_Quit; cdecl; external SDL_MixerLibName;
+
 function  Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName;
 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
 
@@ -697,16 +705,17 @@
 
 (*  SDL_image  *)
 function  IMG_Init(flags: LongInt): LongInt; cdecl; external SDL_ImageLibName;
+procedure IMG_Quit; cdecl; external SDL_ImageLibName;
+
 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
-procedure IMG_Quit; cdecl; external SDL_ImageLibName;
 
 (*  SDL_net  *)
 function  SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
 procedure SDLNet_Quit; cdecl; external SDL_NetLibName;
 
 function  SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName;
-function  SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName;
+function  SDLNet_ResolveHost(var address: TIPaddress; host: PChar; port: Word): LongInt; cdecl; external SDL_NetLibName;
 function  SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName;
 function  SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName;
 function  SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName;
@@ -722,6 +731,10 @@
 function  SDLNet_Read16(buf: pointer): Word;
 function  SDLNet_Read32(buf: pointer): LongWord;
 
+{$IFDEF IPHONEOS}
+function get_documents_path: PChar; cdecl; external 'hwutils';
+{$ENDIF}
+
 implementation
 
 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
--- a/hedgewars/getdocumentpath.m	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/getdocumentpath.m	Sun Jan 03 15:40:41 2010 +0000
@@ -3,6 +3,5 @@
 const char* get_documents_path() {
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
     NSString *documentsDirectory = [paths objectAtIndex: 0];
-    const char* path = [documentsDirectory UTF8String];
-    return path;
+    return [documentsDirectory UTF8String];
 }
--- a/hedgewars/hwengine.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/hwengine.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -161,7 +161,7 @@
 {$IFDEF TOUCHINPUT}
 type TDirection = (nodir, left, right);
 var x, y, dx, dy, mouseState: LongInt;
-    tiltValue: LongInt;
+//    tiltValue: LongInt;
     direction: TDirection = nodir;
     movedbybuttons: boolean = false;
 {$ENDIF}
@@ -194,8 +194,9 @@
 {$IFDEF DEBUGFILE}
                         AddFileLog('*********************************************       motion');
 {$ENDIF}
-                        mouseState:= SDL_GetMouseState(0, @x, @y);
-                        SDL_GetRelativeMouseState(0, @dx, @dy);
+						SDL_SelectMouse(event.motion.which);
+                        mouseState:= SDL_GetMouseState(@x, @y);
+                        SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
                         
                         direction:= nodir;
 
@@ -231,8 +232,9 @@
 {$IFDEF DEBUGFILE}
                         AddFileLog('*********************************************       touch down');
 {$ENDIF}
-                        mouseState:= SDL_GetMouseState(0, @x, @y);                       
-
+						SDL_SelectMouse(event.motion.which);
+                        mouseState:= SDL_GetMouseState(@x, @y);
+                        SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
                         {* attack *}
                         if (x > 50) and (x <= 270) and (y <= 50) then
                         begin
@@ -269,8 +271,10 @@
                         AddFileLog('*********************************************       touch up');
 {$ENDIF}
 
-                        mouseState:= SDL_GetMouseState(0, @x, @y);
-                        uKeys.leftClick:= true;
+						SDL_SelectMouse(event.motion.which);
+                        mouseState:= SDL_GetMouseState(@x, @y);
+                        SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
+						uKeys.leftClick:= true;
 
                         {* open ammo menu *}
                         if (y > 430) and (x > 270) then
@@ -399,7 +403,7 @@
      val(ParamStr(5), ipcPort);
      cFullScreen:= ParamStr(6) = '1';
      isSoundEnabled:= ParamStr(7) = '1';
-     isSoundHardware:= ParamStr(8) = '1';
+     cVSyncInUse:= ParamStr(8) = '1';
      cLocaleFName:= ParamStr(9);
      val(ParamStr(10), cInitVolume);
      val(ParamStr(11), cTimerInterval);
@@ -564,16 +568,14 @@
 
 SDL_EnableUNICODE(1);
 
-WriteToConsole('Init SDL_image... ');
-SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true);
-WriteLnToConsole(msgOK);
-
 WriteToConsole('Init SDL_ttf... ');
 SDLTry(TTF_Init <> -1, true);
 WriteLnToConsole(msgOK);
 
 ShowMainWindow;
 
+AddProgress;
+
 ControllerInit; // has to happen before InitKbdKeyTable to map keys
 InitKbdKeyTable;
 
@@ -598,8 +600,6 @@
 if isSoundEnabled then
 	InitSound;
 
-StoreInit;
-
 isDeveloperMode:= false;
 
 TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
--- a/hedgewars/uConsts.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uConsts.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -31,6 +31,7 @@
 	uLocale;
 
 {$INCLUDE "proto.inc"}
+
 type
 
 	TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit);
--- a/hedgewars/uKeys.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uKeys.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -105,13 +105,12 @@
 // move cursor/camera
 // TODO: Scale on screen dimensions and/or axis value (game controller)?
 movecursor(5 * CursorMovementX, 5 * CursorMovementY);
-		  
+
+k:= SDL_GetMouseState(nil, nil);
 {$IFDEF SDL13}
-pkbd := SDL_GetKeyboardState(@j);
-k    := SDL_GetMouseState(0, nil, nil);
+pkbd:= SDL_GetKeyboardState(@j);
 {$ELSE}
-pkbd := SDL_GetKeyState(@j);
-k    := SDL_GetMouseState(nil, nil);
+pkbd:= SDL_GetKeyState(@j);
 {$ENDIF}
 
 {$IFNDEF IPHONEOS}
@@ -212,12 +211,11 @@
     pkbd: PByteArray;
 begin
 
+k:= SDL_GetMouseState(nil, nil);
 {$IFDEF SDL13}
 pkbd:= SDL_GetKeyboardState(@j);
-k:= SDL_GetMouseState(0, nil, nil);
 {$ELSE}
 pkbd:= SDL_GetKeyState(@j);
-k:= SDL_GetMouseState(nil, nil);
 {$ENDIF}
 TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(j) + ')', true);
 
@@ -241,6 +239,7 @@
 tkbdn[5]:= ord(wheelUp);
 wheelUp:= false;
 wheelDown:= false;
+
 {$IFDEF IPHONEOS}
 tkbdn[1]:= ord(leftClick);
 tkbdn[2]:= ord(middleClick);
@@ -323,14 +322,14 @@
 
 //for i:= 0 to cKeyMaxIndex do writeln(stdout,inttostr(i) + ': ' + KeyNames[i]);
 
+// get the size of keyboard array
 {$IFDEF SDL13}
-PByteArray(SDL_GetKeyboardState(@i));
+SDL_GetKeyboardState(@k);
 {$ELSE}
-SDL_GetKeyState(@i);
+SDL_GetKeyState(@k);
 {$ENDIF}
 
 // Controller(s)
-k:= i;
 for j:= 0 to Pred(ControllerNumControllers) do
 	begin
 	for i:= 0 to Pred(ControllerNumAxes[j]) do
--- a/hedgewars/uLandObjects.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uLandObjects.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -364,6 +364,9 @@
 	end;
 
 begin
+
+AddProgress;
+
 s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
 WriteLnToConsole('Reading objects info...');
 Assign(f, s);
@@ -442,7 +445,8 @@
 
 Close(f);
 {$I+}
-TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true)
+TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true);
+AddProgress;
 end;
 
 procedure AddThemeObjects(var ThemeObjects: TThemeObjects; MaxCount: LongInt);
--- a/hedgewars/uLandTemplates.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uLandTemplates.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -1325,7 +1325,7 @@
        (x: 2047; y:    0)
       );
 ////////////////////////////// ... Silly ...  ////////////////////////////////
-/// Ok. Tiy doesn't care for these.  Perhaps they could be saved.
+/// Ok. Tiy does not care for these.  Perhaps they could be saved.
 /// For now, just rare.
 //////////////////////////////////////////////////////////////////////////////
 
--- a/hedgewars/uMisc.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uMisc.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -34,7 +34,6 @@
 	isInLag         : boolean = false;
 	isPaused        : boolean = false;
 	isSoundEnabled  : boolean = true;
-	isSoundHardware : boolean = false;
 	isMusicEnabled  : boolean = false;
 	isSEBackup      : boolean = true;
 	isInMultiShoot  : boolean = false;
@@ -60,6 +59,7 @@
 	cScreenHeight    : LongInt = 768;
 	cInitWidth       : LongInt = 1024;
 	cInitHeight      : LongInt = 768;
+	cVSyncInUse	 : boolean = true;	
 	cBits            : LongInt = 32;
 	cBitsStr         : string[2] = '32';
 	cTagsMaskIndex   : byte = Low(cTagsMasks);
@@ -111,7 +111,6 @@
 	cBombsSpeed   : hwFloat = (isNegative: false; QWordValue:    429496729);
 {$WARNINGS ON}
 
-var
 	cSendCursorPosTime   : LongWord = 50;
 	ShowCrosshair : boolean;
 	CursorMovementX : Integer = 0;
@@ -192,11 +191,8 @@
 var x, y: LongInt;
 begin
 if (dx = 0) and (dy = 0) then exit;
-{$IFDEF SDL13}
-SDL_GetMouseState(0, @x, @y);
-{$ELSE}
+
 SDL_GetMouseState(@x, @y);
-{$ENDIF}
 Inc(x, dx);
 Inc(y, dy);
 SDL_WarpMouse(x, y);
--- a/hedgewars/uSound.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uSound.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -70,21 +70,26 @@
 procedure InitSound;
 var i: TSound;
 begin
-if not isSoundEnabled then exit;
-WriteToConsole('Init sound...');
-isSoundEnabled:= SDL_Init(SDL_INIT_AUDIO) >= 0;
-if isSoundEnabled then
-   isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0;
-if isSoundEnabled then WriteLnToConsole(msgOK)
-                  else WriteLnToConsole(msgFailed);
-Mix_AllocateChannels(Succ(chanTPU));
-if isMusicEnabled then Mix_VolumeMusic(50);
+	if not isSoundEnabled then exit;
+	WriteToConsole('Init sound...');
+	isSoundEnabled:= SDL_Init(SDL_INIT_AUDIO) >= 0;
+
+	if isSoundEnabled then
+		isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0;
 
-for i:= Low(TSound) to High(TSound) do
-	lastChan[i]:= -1;
+	if isSoundEnabled then
+		WriteLnToConsole(msgOK)
+	else
+		WriteLnToConsole(msgFailed);
 
-Volume:= 0;
-ChangeVolume(cInitVolume)
+	Mix_AllocateChannels(Succ(chanTPU));
+	if isMusicEnabled then
+		Mix_VolumeMusic(50);
+	for i:= Low(TSound) to High(TSound) do
+		lastChan[i]:= -1;
+
+	Volume:= 0;
+	ChangeVolume(cInitVolume)
 end;
 
 procedure ReleaseSound;
@@ -98,7 +103,7 @@
 				Mix_FreeChunk(voicepacks[t].chunks[i]);
 
 Mix_FreeMusic(Mus);
-Mix_CloseAudio
+Mix_CloseAudio();
 end;
 
 procedure SoundLoad;
@@ -106,9 +111,13 @@
 	s: shortstring;
 	t: Longword;
 begin
-if not isSoundEnabled then exit;
+	if not isSoundEnabled then exit;
 
-defVoicepack:= AskForVoicepack('Default');
+	WriteToConsole('Init SDL_mixer... ');
+	SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true);
+	WriteLnToConsole(msgOK);
+	
+	defVoicepack:= AskForVoicepack('Default');
 
 for i:= Low(TSound) to High(TSound) do
 	if (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then
@@ -133,6 +142,8 @@
 				else
 					WriteLnToConsole(msgOK)
 				end;
+	
+	Mix_Quit();
 end;
 
 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack);
--- a/hedgewars/uStore.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uStore.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -28,7 +28,6 @@
 {$ENDIF}
 uFloat;
 
-procedure StoreInit;
 procedure StoreLoad;
 procedure StoreRelease;
 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
@@ -55,13 +54,13 @@
 procedure RenderHealth(var Hedgehog: THedgehog);
 procedure AddProgress;
 procedure FinishProgress;
-function  LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface;
+function  LoadImage(const filename: string; imageFlags: LongInt): PSDL_Surface;
 procedure SetupOpenGL;
 procedure SetScale(f: GLfloat);
 
 
 var PixelFormat: PSDL_PixelFormat = nil;
- SDLPrimSurface: PSDL_Surface = nil;
+   SDLPrimSurface: PSDL_Surface = nil;
    PauseTexture,
    SyncTexture,
    ConfirmTexture: PTexture;
@@ -73,15 +72,9 @@
 
 type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel);
 
-var
-    HHTexture: PTexture;
+var	HHTexture: PTexture;
 	MaxTextureSize: Integer;
-	cGPUVendor: TGPUVendor;
-
-procedure StoreInit;
-begin
-	cGPUVendor:= gvUnknown;
-end;
+	{$IFNDEF IPHONEOS}cGPUVendor: TGPUVendor = gvUnknown;{$ENDIF}
 
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 var r: TSDL_Rect;
@@ -266,8 +259,6 @@
     i: LongInt;
 begin
 
-AddProgress;
-
 for fi:= Low(THWFont) to High(THWFont) do
 	with Fontz[fi] do
 		begin
@@ -362,7 +353,10 @@
 {$ENDIF}
 AddProgress;
 
+{$IFNDEF IPHONEOS}
+	// remove this ifndef when updating sdl_image
 IMG_Quit();
+{$ENDIF}
 end;
 
 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
@@ -971,16 +965,16 @@
 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16)
 end;
 
-function  LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface;
+function  LoadImage(const filename: string; imageFlags: LongInt): PSDL_Surface;
 var tmpsurf: PSDL_Surface;
     s: shortstring;
-{$IFDEF IPHONEOS}
+{$IFDEF DONTUSE}
     tmpP: PLongWordArray;
     tmpA, tmpR, tmpG, tmpB: LongWord;
     i: LongInt;
 {$ENDIF}
 begin
-	WriteToConsole(msgLoading + filename + '... ');
+	WriteToConsole(msgLoading + filename + ' [flags: ' + inttostr(imageFlags) + ']... ');
 
 	s:= filename + '.png';
 	tmpsurf:= IMG_Load(Str2PChar(s));
@@ -1097,14 +1091,15 @@
 procedure SetupOpenGL;
 var vendor: shortstring;
 begin
-glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
+	glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
+	vendor:= LowerCase(string(pchar(glGetString(GL_VENDOR))));
 
-WriteLnToConsole('OpenGL - Renderer: ' + string(pchar(glGetString(GL_RENDERER))));
 {$IFDEF DEBUGFILE}
-AddFileLog('OpenGL - Vendor: ' + string(pchar(glGetString(GL_VENDOR))));
-AddFileLog('OpenGL - Version: ' + string(pchar(glGetString(GL_VERSION))));
+	AddFileLog('OpenGL - Renderer: ' + string(pchar(glGetString(GL_RENDERER))));
+	AddFileLog('  |----- Vendor: ' + vendor);
+	AddFileLog('  |----- Version: ' + string(pchar(glGetString(GL_VERSION))));
+	AddFileLog('  \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
 {$ENDIF}
-WriteLnToConsole('OpenGL - GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
 
 	if MaxTextureSize = 0 then
 	begin
@@ -1114,7 +1109,7 @@
 {$ENDIF}
 	end;
 
-vendor:= LowerCase(string(pchar(glGetString(GL_VENDOR))));
+{$IFNDEF IPHONEOS}
 if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then
 	cGPUVendor:= gvNVIDIA
 else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then
@@ -1122,8 +1117,6 @@
 else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then
 	cGPUVendor:= gvIntel;
 
-	
-{$IFNDEF IPHONEOS}
 //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two');
 {$ENDIF}
 
@@ -1175,15 +1168,22 @@
 var r: TSDL_Rect;
     texsurf: PSDL_Surface;
 begin
-if Step = 0 then
-   begin
-   WriteToConsole(msgLoading + 'progress sprite: ');
-   texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent);
-   ProgrTex:= Surface2Tex(texsurf, false);
-   SDL_FreeSurface(texsurf);
-   squaresize:= ProgrTex^.w shr 1;
-   numsquares:= ProgrTex^.h div squaresize;
-   end;
+	if Step = 0 then
+	begin
+	{$IFNDEF IPHONEOS}
+	// remove this ifndef when updating sdl_image
+		WriteToConsole('Init SDL_image... ');
+		SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true);
+		WriteLnToConsole(msgOK);
+	{$ENDIF}
+	
+		WriteToConsole(msgLoading + 'progress sprite: ');
+		texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent);
+		ProgrTex:= Surface2Tex(texsurf, false);
+		SDL_FreeSurface(texsurf);
+		squaresize:= ProgrTex^.w shr 1;
+		numsquares:= ProgrTex^.h div squaresize;
+	end;
 
 TryDo(ProgrTex <> nil, 'ProgrTex = nil!', true);
 
--- a/hedgewars/uVisualGears.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uVisualGears.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -340,7 +340,7 @@
 	t: Longword;
 	sp: hwFloat;
 begin
-if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we're scrolling now
+if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we are scrolling now
 	if Kind <> vgtCloud then
 		begin
 		AddVisualGear:= nil;
--- a/hedgewars/uWorld.pas	Thu Dec 24 13:38:20 2009 +0000
+++ b/hedgewars/uWorld.pas	Sun Jan 03 15:40:41 2010 +0000
@@ -346,7 +346,7 @@
 
 {$IFDEF IPHONEOS}
 {* see the code in MainLoop *}
-SDL_GetMouseState(0, @x, @y);
+SDL_GetMouseState(@x, @y);
 if ((x > 50) and (x <= 270) and (y > 50) and (y <= 330)) then
 {$ENDIF}
 if not isPaused then MoveCamera;
@@ -641,11 +641,7 @@
 begin
 if (not (CurrentTeam^.ExtDriven and isCursorVisible)) and cHasFocus then
 	begin
-{$IFDEF SDL13}
-	SDL_GetMouseState(0, @CursorPoint.X, @CursorPoint.Y);
-{$ELSE}
 	SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
-{$ENDIF}
 	CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1);
 	CursorPoint.Y:= cScreenHeight - CursorPoint.Y;
 	end;
Binary file share/hedgewars/Data/Themes/Island/Sky-lowres.png has changed