FORUMS
Remove All Ads from XDA

[UTILITY] Lua 5.1 tools: compiler, decompiler, snippets & extendable lua.dll with SDK

1,061 posts
Thanks Meter: 877
 
Post Reply Email Thread
2nd March 2009, 06:44 PM |#171  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by smotrs

Wow, you are just awesome. I'm just trying to decomp one file and your pumping them out left and right. Gonna try some of your newly posted tips and see how much further I can get on the HD version of that file.

Keep up the good work.

Got a rack of Cola for present
 
 
2nd March 2009, 06:45 PM |#172  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by 12aon

Ok problem: I'm trying to change the landscape and portrait phototab but tehy are somehow dependent on one another

here''s the original:

Code:
-- Decompiled using luadec 0.4 by sztupy (http://winmo.sztupy.hu)
-- Command line was: -l 14;0;; 35a10783_manila.luac 

trace("Album Landscape")
require("Common\\LayoutInfo")
_LayoutInfo = LayoutInfo()
Album_ScreenRotation = class(RotationTemplate)
local l_0_0 = Album_ScreenRotation
l_0_0.__init = function(l_1_0, l_1_1)
   l_1_0._ResetLayoutCallback = l_1_1
   trace("Album_ScreenRotation:__init later")
   RotationTemplate.__init(l_1_0)
end

l_0_0 = Album_ScreenRotation
l_0_0.OnScreenRotation = function(l_2_0)
   Camera2DBegin.Viewport.value = RectF(0, 0, screenWidth, screenHeight - 2 * SystemTitlebarHeight)
   Camera2DBegin.ViewLeft.value = 0
   Camera2DBegin.ViewRight.value = screenWidth
   Camera2DBegin.ViewTop.value = 0
   Camera2DBegin.ViewButtom.value = -(screenHeight - 2 * SystemTitlebarHeight)
   Listview3DCamera.Viewport.value = RectF(0, 0, screenWidth, screenHeight - 2 * SystemTitlebarHeight)
   Listview3DCamera.ViewLeft.value = 0
   Listview3DCamera.ViewRight.value = screenWidth
   Listview3DCamera.ViewTop.value = 0
   Listview3DCamera.ViewButtom.value = screenHeight - 2 * SystemTitlebarHeight
   if _application.Orientation == ScreenOrientation_Portrait then
      trace("Album_ScreenRotation_Portrait")
      Listview3DCamera.CameraPosition.value = Vector3(0, 50, 415)
      ControlPanel2D.Position.x = 0
      ControlPanel2D.Position.y = 0
      ArrowGroups.Position.y = -322
      KeyUpSprit.Position.y = 60
      KeyUpSprit.Size.height = 130
      InitPortraitConstant()
   else
      if _application.Orientation == ScreenOrientation_Landscape then
         trace("Album_ScreenRotation_Landscape")
         Listview3DCamera.CameraPosition.value = Vector3(0, 50, 224)
         ControlPanel2D.Position.x = 307
         ControlPanel2D.Position.y = SystemTitlebarHeight
         ArrowGroups.Position.y = -272
         KeyUpSprit.Position.y = 10
         KeyUpSprit.Size.height = 80
         RightBound = 674
         PanoramaWidth = 344
         PanoramaHeight = 120
         PanoramaVWidth = 108
         PanoramaVHeight = 176
         PortraitWidth = 132
         PortraitHeight = 176
         LandscapeWidth = 200
         LandscapeHeight = 150
         WideLandscapeWidth = 250
         WideLandscapeHeight = 150
         ParaOff = 0
         LOff = -5
         WLOff = 0
         POff = -7
         VParaOff = -7
         PhotoHitTarget.Position.x = 212
         PhotoHitTarget.Position.y = -36
         PhotoHitTarget.Size.width = 360
         PhotoHitTarget.Size.height = 300
which I have changed into:
Code:
-- Decompiled using luadec 0.4 by sztupy (http://winmo.sztupy.hu)
-- Command line was: -l 14;0;; 35a10783_manila.luac 

trace("Album Landscape")
require("Common\\LayoutInfo")
_LayoutInfo = LayoutInfo()
Album_ScreenRotation = class(RotationTemplate)
local l_0_0 = Album_ScreenRotation
l_0_0.__init = function(l_1_0, l_1_1)
   l_1_0._ResetLayoutCallback = l_1_1
   trace("Album_ScreenRotation:__init later")
   RotationTemplate.__init(l_1_0)
end

l_0_0 = Album_ScreenRotation
l_0_0.OnScreenRotation = function(l_2_0)
   Camera2DBegin.Viewport.value = RectF(0, 0, 640, 480 - 2 * 50)
   Camera2DBegin.ViewLeft.value = 0
   Camera2DBegin.ViewRight.value = 640
   Camera2DBegin.ViewTop.value = 0
   Camera2DBegin.ViewButtom.value = -(480 - 2 * 50)
   Listview3DCamera.Viewport.value = RectF(0, 0, 480, 640 - 2 * 50)
   Listview3DCamera.ViewLeft.value = 0
   Listview3DCamera.ViewRight.value = 480
   Listview3DCamera.ViewTop.value = 0
   Listview3DCamera.ViewButtom.value = 640 - 2 * 50
   if _application.Orientation == ScreenOrientation_Portrait then
      trace("Album_ScreenRotation_Portrait")
      Listview3DCamera.CameraPosition.value = Vector3(0, 50, 415)
      ControlPanel2D.Position.x = 0
      ControlPanel2D.Position.y = 0
      ArrowGroups.Position.y = -322
      KeyUpSprit.Position.y = 60
      KeyUpSprit.Size.height = 130
      InitPortraitConstant()
   else
      if _application.Orientation == ScreenOrientation_Landscape then
         trace("Album_ScreenRotation_Landscape")
         Listview3DCamera.CameraPosition.value = Vector3(0, 50, 224)
         ControlPanel2D.Position.x = 307
         ControlPanel2D.Position.y = SystemTitlebarHeight
         ArrowGroups.Position.y = -272
         KeyUpSprit.Position.y = 10
         KeyUpSprit.Size.height = 80
         RightBound = 539
         PanoramaWidth = 344
         PanoramaHeight = 120
         PanoramaVWidth = 108
         PanoramaVHeight = 176
         PortraitWidth = 132
         PortraitHeight = 176
         LandscapeWidth = 200
         LandscapeHeight = 150
         WideLandscapeWidth = 250
         WideLandscapeHeight = 150
         ParaOff = 0
         LOff = -5
         WLOff = 0
         POff = -7
         VParaOff = -7
         PhotoHitTarget.Position.x = 212
         PhotoHitTarget.Position.y = -36
         PhotoHitTarget.Size.width = 360
         PhotoHitTarget.Size.height = 300
      end
   end

What do you mean by dependent? (btw. use 0 as the first number in your LDS)
2nd March 2009, 07:14 PM |#173  
smotrs's Avatar
Senior Member
Flag So. Calif.
Thanks Meter: 0
 
More
Quote:
Originally Posted by sztupy

The new "fast guess" mode usually works very fine with _large_ scripts (more than 10k). For smaller ones the original mode usually gets better results, but smaller scripts have already been decompiled

Usage:

Code:
luadecguess -fg 1 filename
the last line it outputs will be the LDS string. Sometimes (well around 50% of the cases) this LDS string will make luadec crash, which means the fast guessed LDS wasn't fine.

To solve this issue one have to run luadec with the -d option set (and with the LDS), and check on where it crashed (which function, which opcode). Then you have to manually modify the LDS string (usually putting a smaller number in the appropriate place should do the job) To get the appropriate "smaller number", luadecguess with fg mode on will list out useful informations about where locals can be defined.

Great information, I put everything into a debug file so I can look at the relevant information and see what's there. What I don't see though is where the crash occurred.

It spewed out a whole bunch of lines and then finished with the following on the screen

Code:
----------------------------------------------
        5       LOADK           0 3

next bool: 1
locals(1): 0{l_11_0}
vpend(0):
tpend(1): 0{l_11_0}
()
    -- DECOMPILER ERROR: Overwrote pending register. Missing locals? Creating them

   local l_11_0 = ""

----------------------------------------------
        6       GETGLOBAL       1 4

Exps(0): at 3   dest 6  neg 1   (cityListSize < 10) cpd -1

Stored at endif list: <6>
I think it's referring to function 5, but I'm not sure. Also, I got the same output with and without a 0 as the first LDS number.
3rd March 2009, 12:54 AM |#174  
12aon's Avatar
Retired Senior Moderator
Thanks Meter: 461
 
Donate to Me
More
Quote:
Originally Posted by sztupy

What do you mean by dependent? (btw. use 0 as the first number in your LDS)

Could you explain a little more, about how to add th numbers in the locals (that's what LDS is right?). I don't understand yet. As for the script, when I change the red values in the script it changes landscape size as well as portrait size. In that way dependent, and now I'm wondering how to change the landscape independently, so I hoped any of the more experienced scripters would know what I'm doing wrong, 12
3rd March 2009, 07:47 AM |#175  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by smotrs

Great information, I put everything into a debug file so I can look at the relevant information and see what's there. What I don't see though is where the crash occurred.

It spewed out a whole bunch of lines and then finished with the following on the screen

Code:
----------------------------------------------
        5       LOADK           0 3

next bool: 1
locals(1): 0{l_11_0}
vpend(0):
tpend(1): 0{l_11_0}
()
    -- DECOMPILER ERROR: Overwrote pending register. Missing locals? Creating them

   local l_11_0 = ""

----------------------------------------------
        6       GETGLOBAL       1 4

Exps(0): at 3   dest 6  neg 1   (cityListSize < 10) cpd -1

Stored at endif list: <6>
I think it's referring to function 5, but I'm not sure. Also, I got the same output with and without a 0 as the first LDS number.

No, unfortunately the debug output of luadec doesn't write out the function number. only the opcode number (should fix that). The opcode number it crashed was 6 (it's the number before GETGLOBAL). For the function number, you have to turn back before the 1st opcode, where you find something like this: "121 CLOSURE", which means this function was defined at the 121th opcode in the main body. Now look ad the luadisasm'd output, where you find at the 121th opcode which function this was (0 based, so the 1st function will be Function #0... luadec is 1st based, so the first function will be #1 just to confuse everyone )

After that you'll want to only decompile this particular function. For example if this was the 5th function, then write for example

luadec -f 5 -l ;;;;;0,0,5 lua.luac

(as you see I've put 5 semicolons before the first number). You always have to put as many 0's as parameters the function have, then a number for each opcode where a local is defined as the appropriate register.
3rd March 2009, 07:52 AM |#176  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by 12aon

Could you explain a little more, about how to add th numbers in the locals (that's what LDS is right?). I don't understand yet. As for the script, when I change the red values in the script it changes landscape size as well as portrait size. In that way dependent, and now I'm wondering how to change the landscape independently, so I hoped any of the more experienced scripters would know what I'm doing wrong, 12

That code looks like:
Code:
SetSomeValues
if Portrait then
  SetSomeValuesForPortrait
else if Landscape
  SetSomeValuesForLandscape
end
what you want to change is in the "SetSomeValues" section. You have to put in both of the "SetSomeValuesForPortrait" and "SetSomeValuesForLandscape" and than change them there:

Code:
Album_ScreenRotation.OnScreenRotation = function(l_2_0)
   if _application.Orientation == ScreenOrientation_Portrait then
      trace("Album_ScreenRotation_Portrait")
      Camera2DBegin.Viewport.value = RectF(0, 0, 640, 480 - 2 * 50)
      Camera2DBegin.ViewLeft.value = 0
      Camera2DBegin.ViewRight.value = 640
      Camera2DBegin.ViewTop.value = 0
      Camera2DBegin.ViewButtom.value = -(480 - 2 * 50)
      Listview3DCamera.Viewport.value = RectF(0, 0, 480, 640 - 2 * 50)
      Listview3DCamera.ViewLeft.value = 0
      Listview3DCamera.ViewRight.value = 480
      Listview3DCamera.ViewTop.value = 0
      Listview3DCamera.ViewButtom.value = 640 - 2 * 50
      Listview3DCamera.CameraPosition.value = Vector3(0, 50, 415)
      ControlPanel2D.Position.x = 0
      ControlPanel2D.Position.y = 0
      ArrowGroups.Position.y = -322
      KeyUpSprit.Position.y = 60
      KeyUpSprit.Size.height = 130
      InitPortraitConstant()
   elseif _application.Orientation == ScreenOrientation_Landscape then
         trace("Album_ScreenRotation_Landscape")
         Camera2DBegin.Viewport.value = RectF(0, 0, 640, 480 - 2 * 50)
         Camera2DBegin.ViewLeft.value = 0
         Camera2DBegin.ViewRight.value = 640
         Camera2DBegin.ViewTop.value = 0
         Camera2DBegin.ViewButtom.value = -(480 - 2 * 50)
         Listview3DCamera.Viewport.value = RectF(0, 0, 480, 640 - 2 * 50)
         Listview3DCamera.ViewLeft.value = 0
         Listview3DCamera.ViewRight.value = 480
         Listview3DCamera.ViewTop.value = 0
         Listview3DCamera.ViewButtom.value = 640 - 2 * 50
         Listview3DCamera.CameraPosition.value = Vector3(0, 50, 224)
         ControlPanel2D.Position.x = 307
         ControlPanel2D.Position.y = SystemTitlebarHeight
         ArrowGroups.Position.y = -272
         KeyUpSprit.Position.y = 10
         KeyUpSprit.Size.height = 80
         RightBound = 539
         PanoramaWidth = 344
         PanoramaHeight = 120
         PanoramaVWidth = 108
         PanoramaVHeight = 176
         PortraitWidth = 132
         PortraitHeight = 176
         LandscapeWidth = 200
         LandscapeHeight = 150
         WideLandscapeWidth = 250
         WideLandscapeHeight = 150
         ParaOff = 0
         LOff = -5
         WLOff = 0
         POff = -7
         VParaOff = -7
         PhotoHitTarget.Position.x = 212
         PhotoHitTarget.Position.y = -36
         PhotoHitTarget.Size.width = 360
         PhotoHitTarget.Size.height = 300
   end
end
3rd March 2009, 10:17 AM |#177  
12aon's Avatar
Retired Senior Moderator
Thanks Meter: 461
 
Donate to Me
More
Quote:
Originally Posted by sztupy

That code looks like:

Code:
SetSomeValues
if Portrait then
  SetSomeValuesForPortrait
else if Landscape
  SetSomeValuesForLandscape
end
what you want to change is in the "SetSomeValues" section. You have to put in both of the "SetSomeValuesForPortrait" and "SetSomeValuesForLandscape" and than change them there:

In my case I should change the l_0_0 and l_1_0 etc right? You added an entire landscape function set that the original didn't have, that's because it's an example or is this the actual code I should use?

Code:
trace("Album Landscape")
require("Common\\LayoutInfo")
_LayoutInfo = LayoutInfo()
Album_ScreenRotation = class(RotationTemplate)
local l_0_0 = Album_ScreenRotation
l_0_0.__init = function(l_1_0, l_1_1)
   l_1_0._ResetLayoutCallback = l_1_1
   trace("Album_ScreenRotation:__init later")
   RotationTemplate.__init(l_1_0)
end

l_0_0 = Album_ScreenRotation
l_0_0.OnScreenRotation = function(l_2_0)
   Camera2DBegin.Viewport.value = RectF(0, 0, screenWidth, screenHeight - 2 * SystemTitlebarHeight)
   Camera2DBegin.ViewLeft.value = 0
   Camera2DBegin.ViewRight.value = screenWidth
   Camera2DBegin.ViewTop.value = 0
   Camera2DBegin.ViewButtom.value = -(screenHeight - 2 * SystemTitlebarHeight)
Xboxmod found a way to edit landscape by editing landscape by editing the red line in the script, so I might fool around with that a bit too. Thanks for the info. Are getting the decompile sickness yet , 12

Code:
      if _application.Orientation == ScreenOrientation_Landscape then
         trace("Album_ScreenRotation_Landscape")
         Listview3DCamera.CameraPosition.value = Vector3(0, 50, 224)
         ControlPanel2D.Position.x = 307
         ControlPanel2D.Position.y = SystemTitlebarHeight
         ArrowGroups.Position.y = -272
         KeyUpSprit.Position.y = 10
         KeyUpSprit.Size.height = 80
         RightBound = 674
3rd March 2009, 03:56 PM |#178  
smotrs's Avatar
Senior Member
Flag So. Calif.
Thanks Meter: 0
 
More
Quote:
Originally Posted by sztupy

No, unfortunately the debug output of luadec doesn't write out the function number. only the opcode number (should fix that). The opcode number it crashed was 6 (it's the number before GETGLOBAL). For the function number, you have to turn back before the 1st opcode, where you find something like this: "121 CLOSURE", which means this function was defined at the 121th opcode in the main body. Now look ad the luadisasm'd output, where you find at the 121th opcode which function this was (0 based, so the 1st function will be Function #0... luadec is 1st based, so the first function will be #1 just to confuse everyone )

After that you'll want to only decompile this particular function. For example if this was the 5th function, then write for example

luadec -f 5 -l ;;;;;0,0,5 lua.luac

(as you see I've put 5 semicolons before the first number). You always have to put as many 0's as parameters the function have, then a number for each opcode where a local is defined as the appropriate register.

So when I look for the line similar to the "121 closure" is this in the output of the luadec or luadecguess? I couldn't find anything like that at the begining of the luadec output, but found this at the begining of the luadecguess output,
Code:
Main Block
  Parameters: 0
  Last relevant lines:
379 [-]: CLOSURE   R0 49        ; R0 := closure(Function #49)
380 [-]: SETGLOBAL R0 K171      ; OnMenuExit := R0
  Last register: 0
  Register assignment dump:
    R0: 0,1,4,7,10,13,15,18,22,24,26,28,30,32,34,36,38,40,42,44,46,48,51,53,55,57,59,61,63,65,67,69,71,75,80,84,87,89,91,94,97,100,102,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,172,182,192,195,198,201,203,205,207,209,212,214,216,219,223,226,231,233,240,242,245,247,249,255,258,262,265,268,271,273,275,277,279,281,283,285,287,289,292,294,300,304,308,310,316,320,323,327,329,333,335,339
    R1: 0,2,5,8,11,85,92,95,98,103,196,199,215,224,227,234,237,266,269,305,321,324,330,336
    R2: 0,20,77,82,174
    R3: 0,21,175,178
    R4: 0,179,189,230,298,314
    R5: 0,177,187
3rd March 2009, 06:26 PM |#179  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by smotrs

So when I look for the line similar to the "121 closure" is this in the output of the luadec or luadecguess? I couldn't find anything like that at the begining of the luadec output, but found this at the begining of the luadecguess output,

Code:
Main Block
  Parameters: 0
  Last relevant lines:
379 [-]: CLOSURE   R0 49        ; R0 := closure(Function #49)
380 [-]: SETGLOBAL R0 K171      ; OnMenuExit := R0
  Last register: 0
  Register assignment dump:
    R0: 0,1,4,7,10,13,15,18,22,24,26,28,30,32,34,36,38,40,42,44,46,48,51,53,55,57,59,61,63,65,67,69,71,75,80,84,87,89,91,94,97,100,102,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,172,182,192,195,198,201,203,205,207,209,212,214,216,219,223,226,231,233,240,242,245,247,249,255,258,262,265,268,271,273,275,277,279,281,283,285,287,289,292,294,300,304,308,310,316,320,323,327,329,333,335,339
    R1: 0,2,5,8,11,85,92,95,98,103,196,199,215,224,227,234,237,266,269,305,321,324,330,336
    R2: 0,20,77,82,174
    R3: 0,21,175,178
    R4: 0,179,189,230,298,314
    R5: 0,177,187

you have to disassemble it using luadisasm
3rd March 2009, 06:28 PM |#180  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Here are the additions for today:
  • 1 embedded script from home.mode9
  • 1 embedded script from settings.mode9
  • 1 embedded script from musicsonglist.mode9
  • stock_sublayer
  • people/peoplecallhistoryglobal
  • people/peopleupdatepage
  • people/peopleupdateviewpage

enjoy.
Attached Files
File Type: zip touchpro2_manila3d_declua.zip - [Click for QR Code] (607.2 KB, 26 views)
3rd March 2009, 06:33 PM |#181  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by 12aon

In my case I should change the l_0_0 and l_1_0 etc right? You added an entire landscape function set that the original didn't have, that's because it's an example or is this the actual code I should use?

No, I only fixed the decompilation of the main body (removed the l_0_0 lines because they don't have to be there) and put the first 8 lines of the function to both to the landscpae and the portrait part of the conditional statement. If you look closer the function body you'll see it's the same except for these 8 lines
Post Reply Subscribe to Thread

Tags
lua, manila, mod, tf3d, touchflo

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes