added little/big endian checks, added symbol for touch input, simplified iphoneos definitions
--- a/hedgewars/CMakeLists.txt Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/CMakeLists.txt Sun Oct 25 15:55:49 2009 +0000
@@ -96,7 +96,7 @@
set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" ${hwengine_project})
if(OPTIMIZATIONS)
- set(pascal_compiler_flags "-O2" "-Xs" "-Nu" ${pascal_compiler_flags})
+ set(pascal_compiler_flags "-O2" "-Xs" "-Nu" "-Si" ${pascal_compiler_flags})
if(APPLE AND NOT universal_build)
set(pascal_compiler_flags "-fPIC" "-CfSSE2" ${pascal_compiler_flags}) #instruction set for ppc is 7400
endif()
--- a/hedgewars/SDLh.pas Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/SDLh.pas Sun Oct 25 15:55:49 2009 +0000
@@ -19,6 +19,8 @@
unit SDLh;
interface
+{$INCLUDE options.inc}
+
{$IFDEF LINUX or FREEBSD}
{$DEFINE UNIX}
{$ENDIF}
@@ -126,17 +128,17 @@
{*end sdl_event binding*}
-//if little endian
+{$IFDEF ENDIAN_LITTLE}
RMask = $000000FF;
GMask = $0000FF00;
BMask = $00FF0000;
AMask = $FF000000;
-//else
-// RMask = $FF000000;
-// GMask = $00FF0000;
-// BMask = $0000FF00;
-// AMask = $000000FF;
-//endif
+{$ELSE}
+ RMask = $FF000000;
+ GMask = $00FF0000;
+ BMask = $0000FF00;
+ AMask = $000000FF;
+{$ENDIF}
type PSDL_Rect = ^TSDL_Rect;
@@ -281,9 +283,20 @@
SDL_GL_CONTEXT_MAJOR_VERSION,
SDL_GL_CONTEXT_MINOR_VERSION
);
+
{$IFDEF SDL13}
- TSDL_MouseMotionEvent = record
+ TSDL_ArrayByteOrder = ( // array component order, low byte -> high byte
+ SDL_ARRAYORDER_NONE,
+ SDL_ARRAYORDER_RGB,
+ SDL_ARRAYORDER_RGBA,
+ SDL_ARRAYORDER_ARGB,
+ SDL_ARRAYORDER_BGR,
+ SDL_ARRAYORDER_BGRA,
+ SDL_ARRAYORDER_ABGR
+ );
+
+ TSDL_MouseMotionEvent = record
type_: byte;
which: byte;
state: byte;
@@ -323,8 +336,8 @@
state: Byte;
end;
- PSDL_Event = ^TSDL_Event;
- TSDL_Event = record
+ PSDL_Event = ^TSDL_Event;
+ TSDL_Event = record
case Byte of
{$IFDEF SDL13}
//doublecheck the type of WINDOWEVENT TEXTINPUT
@@ -403,6 +416,7 @@
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;
function SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
--- a/hedgewars/hwengine.pas Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/hwengine.pas Sun Oct 25 15:55:49 2009 +0000
@@ -174,7 +174,7 @@
repeat
while SDL_PollEvent(@event) <> 0 do
case event.type_ of
-{$IFDEF IPHONEOS}
+{$IFDEF SDL13}
SDL_WINDOWEVENT:
{$ELSE}
SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode);
@@ -183,7 +183,7 @@
if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
cHasFocus:= event.active.gain = 1;
//SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450));
-{$IFDEF IPHONEOS}
+{$IFDEF TOUCHINPUT}
{*MoveCamera is in uWord.pas -- conflicts with other commands*}
{*Keys are in uKeys.pas*}
SDL_MOUSEBUTTONDOWN: begin
@@ -273,8 +273,6 @@
SDL_MOUSEBUTTONUP: begin
AddFileLog('********************************************* touch up');
- // if bShowAmmoMenu = true then
-
SDL_GetMouseState(0, @x, @y);
{* open ammo menu *}
if (y > 430) and (x > 270) then
@@ -285,6 +283,8 @@
uKeys.rightClick:= true;
end;
end;
+{$ENDIF}
+{$IFDEF IPHONEOS}
SDL_JOYAXIS: begin
{* axis 0 = left and right;
axis 1 = up and down;
--- a/hedgewars/options.inc Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/options.inc Sun Oct 25 15:55:49 2009 +0000
@@ -22,3 +22,8 @@
{ $DEFINE DUMP}
{ $DEFINE TRACEAIACTIONS}
+{$IFDEF IPHONEOS}
+{$DEFINE SDL13}
+{$DEFINE GLES11}
+{$DEFINE TOUCHINPUT}
+{$ENDIF}
\ No newline at end of file
--- a/hedgewars/uConsts.pas Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/uConsts.pas Sun Oct 25 15:55:49 2009 +0000
@@ -1565,17 +1565,17 @@
Gloss : 0;
Bloss : 0;
Aloss : 0;
-//if little endian -> bgra
+{$IFDEF ENDIAN_LITTLE}
Rshift: 0;
Gshift: 8;
Bshift: 16;
Ashift: 24;
-//else -> argb (or rgba?)
-// Rshift: 24;
-// Gshift: 16;
-// Bshift: 8;
-// Ashift: 0;
-//endif
+{$ELSE}
+ Rshift: 24;
+ Gshift: 16;
+ Bshift: 8;
+ Ashift: 0;
+{$ENDIF}
RMask : RMask;
GMask : GMask;
BMask : BMask;
--- a/hedgewars/uGame.pas Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/uGame.pas Sun Oct 25 15:55:49 2009 +0000
@@ -64,7 +64,7 @@
end;
gmtSave: begin
RestoreTeamsFromSave;
-{$IFNDEF IPHONEOS}
+{$IFNDEF TOUCHINPUT}
SetBinds(CurrentTeam^.Binds);
{$ENDIF}
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos
--- a/hedgewars/uKeys.pas Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/uKeys.pas Sun Oct 25 15:55:49 2009 +0000
@@ -42,7 +42,7 @@
var hideAmmoMenu: boolean;
wheelUp: boolean = false;
wheelDown: boolean = false;
-{$IFDEF IPHONEOS}
+{$IFDEF TOUCHINPUT}
leftClick: boolean = false;
middleClick: boolean = false;
rightClick: boolean = false;
@@ -130,7 +130,7 @@
tkbdn[5]:= ord(wheelUp);
wheelUp:= false;
wheelDown:= false;
-{$IFDEF IPHONEOS}
+{$IFDEF TOUCHINPUT}
tkbdn[1]:= ord(leftClick);
tkbdn[2]:= ord(middleClick);
tkbdn[3]:= ord(rightClick);
@@ -344,7 +344,7 @@
end;
end;
-{$IFDEF IPHONEOS}
+{$IFDEF TOUCHINPUT}
DefaultBinds[ 1]:= '/put';
DefaultBinds[ 3]:= 'ammomenu';
DefaultBinds[ 8]:= 'hjump';
--- a/hedgewars/uTeams.pas Sun Oct 25 12:41:48 2009 +0000
+++ b/hedgewars/uTeams.pas Sun Oct 25 15:55:49 2009 +0000
@@ -233,7 +233,7 @@
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
ApplyAmmoChanges(CurrentHedgehog^);
-{$IFNDEF IPHONEOS}
+{$IFNDEF TOUCHINPUT}
if not CurrentTeam^.ExtDriven then SetBinds(CurrentTeam^.Binds);
{$ENDIF}