move mixed functions in PascalExports
authorkoda
Sat, 09 Jan 2010 01:34:23 +0000
changeset 2690 8e83c7e31720
parent 2689 dfda97c153a4
child 2691 c0da3a98c01c
move mixed functions in PascalExports
cocoaTouch/SDLOverrides/SDL_uikitview.m
hedgewars/PascalExports.pas
hedgewars/SDLh.pas
hedgewars/getdocumentpath.m
hedgewars/hwengine.pas
hedgewars/uKeys.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
--- a/cocoaTouch/SDLOverrides/SDL_uikitview.m	Sat Jan 09 00:59:12 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m	Sat Jan 09 01:34:23 2010 +0000
@@ -82,10 +82,15 @@
 }
 
 #pragma mark -
-#pragma mark Show and Hide overlaid buttons
+#pragma mark Exported functions for FreePascal
 
-// standard C function to be called from pascal
-void showControls(void) {
+const char* IPH_getDocumentsPath() {
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    NSString *documentsDirectory = [paths objectAtIndex: 0];
+    return [documentsDirectory UTF8String];
+}
+
+void IPH_showControls (void) {
 	NSLog(@"Showing controls");
 	[UIView beginAnimations:nil context:NULL];
 	[UIView setAnimationDuration:0.5];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/PascalExports.pas	Sat Jan 09 01:34:23 2010 +0000
@@ -0,0 +1,136 @@
+(*
+ *  PascalExports.pas
+ *  hwengine
+ *
+ *  Created by Vittorio on 09/01/10.
+ *  Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ *)
+
+
+{$INCLUDE "options.inc"}
+
+unit PascalExports;
+
+interface
+uses uKeys, uConsole;
+
+{$IFDEF IPHONEOS}
+// called by pascal code, they deal with the objc code
+function  IPH_getDocumentsPath: PChar; cdecl; external;
+procedure IPH_showControls; cdecl; external;
+
+// called by the touch functions (SDL_uikitview.m)
+// they emulate user interaction from mouse or keyboard
+procedure HW_click; cdecl; export;
+procedure HW_zoomIn; cdecl; export;
+procedure HW_zoomOut; cdecl; export;
+procedure HW_zoomReset; cdecl; export;
+procedure HW_ammoMenu; cdecl; export;
+procedure HW_allKeysUp; cdecl; export;
+procedure HW_walkLeft; cdecl; export;
+procedure HW_walkRight; cdecl; export;
+procedure HW_aimUp; cdecl; export;
+procedure HW_aimDown; cdecl; export;
+procedure HW_shoot; cdecl; export;
+procedure HW_whereIsHog; cdecl; export;
+
+{$ENDIF}
+
+implementation
+
+{$IFDEF IPHONEOS}
+procedure HW_click; cdecl; export;
+begin
+	WriteLnToConsole('HW - left click');
+	leftClick:= true;
+	exit
+end;
+
+procedure HW_zoomIn; cdecl; export;
+begin
+	WriteLnToConsole('HW - zooming in');
+	wheelUp:= true;
+	exit
+end;
+
+procedure HW_zoomOut; cdecl; export;
+begin
+	WriteLnToConsole('HW - zooming out');
+	wheelDown:= true;
+	exit
+end;
+
+procedure HW_zoomReset; cdecl; export;
+begin
+	WriteLnToConsole('HW - reset zoom');
+	middleClick:= true;
+	exit
+end;
+
+procedure HW_ammoMenu; cdecl; export;
+begin
+	WriteLnToConsole('HW - right click');
+	rightClick:= true;
+	exit
+end;
+
+procedure HW_allKeysUp; cdecl; export;
+begin
+	WriteLnToConsole('HW - resetting keyboard');
+
+	upKey:= false;
+	downKey:= false;
+	leftKey:= false;
+	rightKey:= false;
+	spaceKey:= false;
+	exit
+end;
+
+procedure HW_walkLeft; cdecl; export;
+begin
+	WriteLnToConsole('HW - walking left');
+	leftKey:= true;
+	exit
+end;
+
+procedure HW_walkRight; cdecl; export;
+begin
+	WriteLnToConsole('HW - walking right');
+	rightKey:= true;
+	exit
+end;
+
+procedure HW_aimUp; cdecl; export;
+begin
+	WriteLnToConsole('HW - aiming upwards');
+	upKey:= true;
+	exit
+end;
+
+procedure HW_aimDown; cdecl; export;
+begin
+	WriteLnToConsole('HW - aiming downwards');
+	downKey:= true;
+	exit
+end;
+
+procedure HW_shoot; cdecl; export;
+begin
+	WriteLnToConsole('HW - shooting');
+	spaceKey:= true;
+	exit
+end;
+
+procedure HW_whereIsHog; cdecl; export;
+var Xcoord, Ycoord: LongInt;
+begin
+	//Xcoord:= Gear^.dX + WorldDx;
+	WriteLnToConsole('HW - hog is at x: ' + ' y:');
+
+	exit
+end;
+{$ENDIF}
+
+end.
+
--- a/hedgewars/SDLh.pas	Sat Jan 09 00:59:12 2010 +0000
+++ b/hedgewars/SDLh.pas	Sat Jan 09 01:34:23 2010 +0000
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *)
 
-{$I "options.inc"}
+{$INCLUDE "options.inc"}
 
 unit SDLh;
 interface
@@ -732,12 +732,6 @@
 procedure SDLNet_Write32(value: LongWord; buf: pointer);
 function  SDLNet_Read16(buf: pointer): Word;
 function  SDLNet_Read32(buf: pointer): LongWord;
-
-{$IFDEF IPHONEOS}
-function  get_documents_path: PChar; cdecl; external 'hwutils';
-procedure IPH_showControls; cdecl; external name 'showControls';
-{$ENDIF}
-
 implementation
 
 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
--- a/hedgewars/getdocumentpath.m	Sat Jan 09 00:59:12 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#import <UIKit/UIKit.h>
-
-const char* get_documents_path() {
-    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-    NSString *documentsDirectory = [paths objectAtIndex: 0];
-    return [documentsDirectory UTF8String];
-}
--- a/hedgewars/hwengine.pas	Sat Jan 09 00:59:12 2010 +0000
+++ b/hedgewars/hwengine.pas	Sat Jan 09 01:34:23 2010 +0000
@@ -19,8 +19,7 @@
 {$INCLUDE "options.inc"}
 
 program hwengine;
-uses
-	SDLh in 'SDLh.pas',
+uses	SDLh in 'SDLh.pas',
 {$IFDEF GLES11}
 	gles11,
 {$ELSE}
@@ -54,7 +53,11 @@
 	uFloat in 'uFloat.pas',
 	uStats in 'uStats.pas',
 	uChat in 'uChat.pas',
-	uLandTexture in 'uLandTexture.pas';
+	uLandTexture in 'uLandTexture.pas'
+	{$IFDEF IPHONEOS}
+	, PascalExports in 'PascalExports.pas'
+	{$ENDIF}
+	;
 
 // also: GSHandlers.inc
 //       CCHandlers.inc
@@ -163,7 +166,7 @@
     CurrTime: Longword;
     event: TSDL_Event;
 {$IFDEF TOUCHINPUT}
-var tiltValue: LongInt;
+//var tiltValue: LongInt;
 {$ENDIF}
 begin
 PrevTime:= SDL_GetTicks;
@@ -411,7 +414,7 @@
 for i:= 0 to ParamCount do
 	AddFileLog(inttostr(i) + ': ' + ParamStr(i));
 {$IFDEF IPHONEOS}
-	WriteLnToConsole('Saving debug file at: ' + get_documents_path());
+	WriteLnToConsole('Saving debug file at: ' + IPH_getDocumentsPath());
 {$ENDIF}
 {$ENDIF}
 end;
--- a/hedgewars/uKeys.pas	Sat Jan 09 00:59:12 2010 +0000
+++ b/hedgewars/uKeys.pas	Sat Jan 09 01:34:23 2010 +0000
@@ -42,22 +42,6 @@
 procedure ControllerHatEvent(joy, hat, value: Byte);
 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
 
-{$IFDEF IPHONEOS}
-procedure HW_click; cdecl; export;
-procedure HW_zoomIn; cdecl; export;
-procedure HW_zoomOut; cdecl; export;
-procedure HW_zoomReset; cdecl; export;
-procedure HW_ammoMenu; cdecl; export;
-procedure HW_allKeysUp; cdecl; export;
-procedure HW_walkLeft; cdecl; export;
-procedure HW_walkRight; cdecl; export;
-procedure HW_aimUp; cdecl; export;
-procedure HW_aimDown; cdecl; export;
-procedure HW_shoot; cdecl; export;
-procedure HW_whereIsHog; cdecl; export;
-
-{$ENDIF}
-
 var	hideAmmoMenu: boolean;
 	wheelUp: boolean = false;
 	wheelDown: boolean = false;
@@ -100,101 +84,6 @@
 var tkbd, tkbdn: TKeyboardState;
     KeyNames: array [0..cKeyMaxIndex] of string[15];
     DefaultBinds, CurrentBinds: TBinds;
-
-{$IFDEF IPHONEOS}
-// these are called by the touch functions present in SDL_uikitview.m
-// they emulate user interaction from mouse or keyboard
-procedure HW_click; cdecl; export;
-begin
-	WriteLnToConsole('HW - left click');
-	leftClick:= true;
-	exit
-end;
-
-procedure HW_zoomIn; cdecl; export;
-begin
-	WriteLnToConsole('HW - zooming in');
-	wheelUp:= true;
-	exit
-end;
-
-procedure HW_zoomOut; cdecl; export;
-begin
-	WriteLnToConsole('HW - zooming out');
-	wheelDown:= true;
-	exit
-end;
-
-procedure HW_zoomReset; cdecl; export;
-begin
-	WriteLnToConsole('HW - reset zoom');
-	middleClick:= true;
-	exit
-end;
-
-procedure HW_ammoMenu; cdecl; export;
-begin
-	WriteLnToConsole('HW - right click');
-	rightClick:= true;
-	exit
-end;
-
-procedure HW_allKeysUp; cdecl; export;
-begin
-	WriteLnToConsole('HW - resetting keyboard');
-
-	upKey:= false;
-	downKey:= false;
-	leftKey:= false;
-	rightKey:= false;
-	spaceKey:= false;
-	exit
-end;
-
-procedure HW_walkLeft; cdecl; export;
-begin
-	WriteLnToConsole('HW - walking left');
-	leftKey:= true;
-	exit
-end;
-
-procedure HW_walkRight; cdecl; export;
-begin
-	WriteLnToConsole('HW - walking right');
-	rightKey:= true;
-	exit
-end;
-
-procedure HW_aimUp; cdecl; export;
-begin
-	WriteLnToConsole('HW - aiming upwards');
-	upKey:= true;
-	exit
-end;
-
-procedure HW_aimDown; cdecl; export;
-begin
-	WriteLnToConsole('HW - aiming downwards');
-	downKey:= true;
-	exit
-end;
-
-procedure HW_shoot; cdecl; export;
-begin
-	WriteLnToConsole('HW - shooting');
-	spaceKey:= true;
-	exit
-end;
-
-procedure HW_whereIsHog; cdecl; export;
-var Xcoord, Ycoord: LongInt;
-begin
-	//Xcoord:= Gear^.dX + WorldDx;
-	WriteLnToConsole('HW - hog is at x: ' + ' y:');
-
-	exit
-end;
-{$ENDIF}
 	
 function KeyNameToCode(name: string): word;
 var code: Word;
--- a/hedgewars/uMisc.pas	Sat Jan 09 00:59:12 2010 +0000
+++ b/hedgewars/uMisc.pas	Sat Jan 09 01:34:23 2010 +0000
@@ -27,7 +27,12 @@
 {$ELSE}
 	GL,
 {$ENDIF}
-	uFloat;
+	uFloat
+{$IFDEF IPHONEOS}
+	, PascalExports
+{$ENDIF}
+	;
+
 var
 	isCursorVisible : boolean = false;
 	isTerminated    : boolean = false;
@@ -585,7 +590,7 @@
 begin
 	assign(f, 
 {$IFDEF IPHONEOS}
-	string(get_documents_path())
+	string(IPH_getDocumentsPath())
 {$ELSE}
 	ParamStr(1)
 {$ENDIF}
--- a/hedgewars/uStore.pas	Sat Jan 09 00:59:12 2010 +0000
+++ b/hedgewars/uStore.pas	Sat Jan 09 01:34:23 2010 +0000
@@ -69,7 +69,11 @@
    SupportNPOTT: Boolean = false;
 
 implementation
-uses uMisc, uConsole, uLand, uLocale, uWorld;
+uses uMisc, uConsole, uLand, uLocale, uWorld
+	{$IFDEF IPHONEOS}
+	, PascalExports
+	{$ENDIF}
+	;
 
 type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel);