Fix sources so pas2c written in haskell could render them again webgl
authorunc0rr
Tue, 19 Feb 2013 22:45:02 +0400
branchwebgl
changeset 8446 c18ba8726f5a
parent 8444 75db7bb8dce8
child 8448 14f736ca7eb3
Fix sources so pas2c written in haskell could render them again
hedgewars/ArgParsers.inc
hedgewars/GSHandlers.inc
hedgewars/VGSHandlers.inc
hedgewars/uGame.pas
hedgewars/uInputHandler.pas
hedgewars/uStore.pas
tools/pas2c/Pas2C.hs
--- a/hedgewars/ArgParsers.inc	Sun Jan 27 00:28:57 2013 +0100
+++ b/hedgewars/ArgParsers.inc	Tue Feb 19 22:45:02 2013 +0400
@@ -160,14 +160,14 @@
     getStringParameter:= str;
 end;
 
-procedure parseClassicParameter(cmdArray: array of String; size:LongInt; var paramIndex:LongInt); forward;
+procedure parseClassicParameter(cmdarray: array of String; size:LongInt; var paramIndex:LongInt); forward;
 
 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean;
-const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
-      audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound');
-      otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps');
-      mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
-      allArray: Array [1..14] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality');
+const videoarray: array [0..4] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
+      audioarray: array [0..2] of String = ('--volume','--nomusic','--nosound');
+      otherarray: array [0..2] of String = ('--locale','--fullscreen','--showfps');
+      mediaarray: array [0..9] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
+      allarray: array [0..13] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality');
       reallyAll: array[0..30] of shortstring = (
                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', 
                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
@@ -205,11 +205,11 @@
         {--nick}                17 : UserNick          := parseNick( getStringParameter(arg, paramIndex, parseParameter) );
         {deprecated options}
         {--depth}               18 : setDepth(paramIndex);
-        {--set-video}           19 : parseClassicParameter(videoArray,5,paramIndex);
-        {--set-audio}           20 : parseClassicParameter(audioArray,3,paramIndex);
-        {--set-other}           21 : parseClassicParameter(otherArray,3,paramIndex);
-        {--set-multimedia}      22 : parseClassicParameter(mediaArray,10,paramIndex);
-        {--set-everything}      23 : parseClassicParameter(allArray,14,paramIndex);
+        {--set-video}           19 : parseClassicParameter(videoarray,5,paramIndex);
+        {--set-audio}           20 : parseClassicParameter(audioarray,3,paramIndex);
+        {--set-other}           21 : parseClassicParameter(otherarray,3,paramIndex);
+        {--set-multimedia}      22 : parseClassicParameter(mediaarray,10,paramIndex);
+        {--set-everything}      23 : parseClassicParameter(allarray,14,paramIndex);
         {"internal" options}
         {--internal}            24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF};
         {--port}                25 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter );
@@ -233,7 +233,7 @@
     end;
 end;
 
-procedure parseClassicParameter(cmdArray: array of String; size:LongInt; var paramIndex:LongInt);
+procedure parseClassicParameter(cmdarray: array of String; size:LongInt; var paramIndex:LongInt);
 var index, tmpInt: LongInt;
     isBool, isValid: Boolean;
     cmd, arg, newSyntax: String;
@@ -249,7 +249,7 @@
         begin
         newSyntax:= '';
         inc(paramIndex);
-        cmd:= cmdArray[index];
+        cmd:= cmdarray[index];
         arg:= ParamStr(paramIndex);
         isValid:= (cmd<>'--depth');
 
@@ -316,7 +316,7 @@
 begin
     isInternal:= (ParamStr(1) = '--internal');
 
-    UserPathPrefix := '.';
+    UserPathPrefix := _S'.';
     PathPrefix     := cDefaultPathPrefix;
     recordFileName := '';
     parseCommandLine();
--- a/hedgewars/GSHandlers.inc	Sun Jan 27 00:28:57 2013 +0100
+++ b/hedgewars/GSHandlers.inc	Tue Feb 19 22:45:02 2013 +0400
@@ -2226,9 +2226,11 @@
         begin
         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
         DeleteGear(Gear);
+        {$IFNDEF PAS2C}
         with mobileRecord do
             if (performRumble <> nil) and (not fastUntilLag) then
                 performRumble(kSystemSoundID_Vibrate);
+        {$ENDIF}
         exit
         end;
     if (GameTicks and $3F) = 0 then
@@ -4318,9 +4320,11 @@
     Gear^.dY.isNegative := not Gear^.dY.isNegative;
 
     Gear^.doStep := @doStepSineGunShotWork;
+    {$IFNDEF PAS2C}
     with mobileRecord do
         if (performRumble <> nil) and (not fastUntilLag) then
             performRumble(kSystemSoundID_Vibrate);
+    {$ENDIF}
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/hedgewars/VGSHandlers.inc	Sun Jan 27 00:28:57 2013 +0100
+++ b/hedgewars/VGSHandlers.inc	Tue Feb 19 22:45:02 2013 +0400
@@ -704,9 +704,12 @@
 Gear^.doStep:= @doStepBigExplosionWork;
 if Steps > 1 then
     Gear^.doStep(Gear, Steps-1);
+
+{$IFNDEF PAS2C}
 with mobileRecord do
     if (performRumble <> nil) and (not fastUntilLag) then
         performRumble(kSystemSoundID_Vibrate);
+{$ENDIF}
 end;
 
 procedure doStepChunk(Gear: PVisualGear; Steps: Longword);
--- a/hedgewars/uGame.pas	Sun Jan 27 00:28:57 2013 +0100
+++ b/hedgewars/uGame.pas	Tue Feb 19 22:45:02 2013 +0400
@@ -96,9 +96,10 @@
                         AddVisualGear(0, 0, vgtTeamHealthSorter);
                         AddVisualGear(0, 0, vgtSmoothWindBar);
                         {$IFDEF IPHONEOS}InitIPC;{$ENDIF}
-                        with mobileRecord do
+                        {$IFNDEF PAS2C}with mobileRecord do
                             if SaveLoadingEnded <> nil then
                                 SaveLoadingEnded();
+                        {$ENDIF}
                         end;
                 end
         else ProcessGears
--- a/hedgewars/uInputHandler.pas	Sun Jan 27 00:28:57 2013 +0100
+++ b/hedgewars/uInputHandler.pas	Tue Feb 19 22:45:02 2013 +0400
@@ -464,7 +464,7 @@
 if (not usingDBinds) then
     begin
     usingDBinds:= true;
-    FillByte(DefaultBinds, SizeOf(DefaultBinds), 0);
+    FillChar(DefaultBinds, SizeOf(DefaultBinds), 0);
     end;
 
 if (Pos('mod:', id) <> 0) then
--- a/hedgewars/uStore.pas	Sun Jan 27 00:28:57 2013 +0100
+++ b/hedgewars/uStore.pas	Tue Feb 19 22:45:02 2013 +0400
@@ -468,6 +468,7 @@
 WriteLnToConsole('Leaving StoreLoad');
 end;
 
+{$IFNDEF PAS2C}
 {$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)}
 procedure CreateFramebuffer(var frame, depth, tex: GLuint);
 begin
@@ -492,6 +493,7 @@
     glDeleteFramebuffersEXT(1, @frame);
 end;
 {$ENDIF}
+{$ENDIF}
 
 procedure StoreRelease(reload: boolean);
 var ii: TSprite;
@@ -566,6 +568,7 @@
                 end;
             end;
         end;
+{$IFNDEF PAS2C}
 {$IFDEF USE_VIDEO_RECORDING}
     if defaultFrame <> 0 then
         DeleteFramebuffer(defaultFrame, depthv, texv);
@@ -577,6 +580,7 @@
         DeleteFramebuffer(framer, depthr, texr);
         end
 {$ENDIF}
+{$ENDIF}
 end;
 
 
@@ -994,6 +998,7 @@
     UpdateModelviewProjection;
 {$ENDIF}
 
+{$IFNDEF PAS2C}
 {$IFNDEF USE_S3D_RENDERING}
     if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
     begin
@@ -1010,6 +1015,7 @@
             cStereoMode:= smNone;
     end;
 {$ENDIF}
+{$ENDIF}
 
 // set view port to whole window
 glViewport(0, 0, cScreenWidth, cScreenHeight);
@@ -1209,10 +1215,11 @@
         squaresize:= texsurf^.w shr 1;
         numsquares:= texsurf^.h div squaresize;
         SDL_FreeSurface(texsurf);
+        {$IFNDEF PAS2C}
         with mobileRecord do
             if GameLoading <> nil then
                 GameLoading();
-
+        {$ENDIF}
         end;
 
     TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true);
@@ -1236,9 +1243,11 @@
 
 procedure FinishProgress;
 begin
+    {$IFNDEF PAS2C}
     with mobileRecord do
         if GameLoaded <> nil then
             GameLoaded();
+    {$ENDIF}
     WriteLnToConsole('Freeing progress surface... ');
     FreeTexture(ProgrTex);
     ProgrTex:= nil;
--- a/tools/pas2c/Pas2C.hs	Sun Jan 27 00:28:57 2013 +0100
+++ b/tools/pas2c/Pas2C.hs	Tue Feb 19 22:45:02 2013 +0400
@@ -786,7 +786,7 @@
     where
     elsePart | isNothing mphrase2 = return $ empty
              | otherwise = liftM (text "else" $$) $ (phrase2C . wrapPhrase) (fromJust mphrase2)
-phrase2C (Assignment ref expr) = do
+phrase2C asgn@(Assignment ref expr) = do
     r <- ref2C ref
     t <- gets lastType
     case (t, expr) of
@@ -804,7 +804,7 @@
                 BTString -> do
                     e <- expr2C expr
                     return $ r <+> text "=" <+> e <> semi
-                _ -> error $ "Assignment to string from " ++ show lt
+                _ -> error $ "Assignment to string from " ++ show asgn
         (BTArray _ _ _, _) -> do
             case expr of
                 Reference er -> do