Yoshin222

SF3:3S: Display Character Data

Oct 29th, 2021
170
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Initialise Variables/Addresses
  2. --Massive thanks to Jesuszilla for the tips/rewrite
  3. local int textx = 2
  4. local int textx2 = 290
  5. local int textx3 = 130
  6. local int texty = 10
  7.     --Memory Macros
  8. rb = memory.readbyte
  9. rw = memory.readword
  10. rd = memory.readdword
  11. wb = memory.writebyte
  12. ww = memory.writeword
  13. wd = memory.writedword
  14.     --SIGNED VALUES
  15. rbs = memory.readbytesigned
  16. rws = memory.readwordsigned
  17. rds = memory.readdwordsigned
  18. wbs = memory.writebytesigned
  19. wws = memory.writewordsigned
  20. wds = memory.writedwordsigned
  21.  
  22. local int text = {
  23. x = 2,
  24. x2 = 40,
  25. x3 = 290,
  26. y = 10,
  27. }
  28.  
  29. local View_Mode = {
  30.     CPS3,
  31.     Mugen,
  32. }
  33. local Current_Mode = 2 --Default, 1= CPS3, 2 = Mugen
  34.  
  35. --ADDRESSES
  36.  
  37. local Player_UID = {
  38. P1 = 0x02068C6C,
  39. P2 = 0x02069104,
  40. } --0x498
  41.  
  42. local Space = Player_UID.P2 - Player_UID.P1
  43. local Current_Player = 0 --0 = P1, 1= P2
  44.  
  45. local UID_Data = {
  46.     visible  = 0x01,
  47.     player_ctrl = 0x02,
  48.     facing   = 0x03,
  49.     Hitpause = 0x45,
  50.     pos_X   = 0x64,
  51.     pos_X_subpixel = 0x66,
  52.     pos_Y   = 0x68,
  53.     pos_Y_subpixel = 0x6A, 
  54.     vel_X   = 0x7C,
  55.     vel_X_Subvel   = 0x7E,
  56.     vel_Y   = 0x80,
  57.     subvel_Y   = 130,
  58.     accel_Y = 136,
  59.     Anim_Pointer = 0x200,
  60.     Animelem_Frametime = 517,
  61.     Internal_Spriteno = 538,
  62.     char_id = 0x3C1,
  63.     Sprite_Header = 604,
  64.     Box_Base = 648, --TEST!!!!
  65.     Pointer_List_1 =  {
  66.         Offset = 428,
  67.         No_of_Pointers = 10
  68.         },
  69.     Pointer_List_2 = {
  70.         Offset = 476,
  71.         No_of_Pointers = 5
  72.         },
  73.     Pointer1 =  504, -- DWORD
  74.     Pointer_List_3 = {
  75.         Offset = 668,
  76.         No_of_Pointers = 4
  77.         },
  78.     Pointer_List_4 = {
  79.         Offset = 692,
  80.         No_of_Pointers = 6
  81.         },
  82.     Pointer_List_5 = {
  83.         Offset = 720,
  84.         No_of_Pointers = 3
  85.         },
  86.     Pointer2 = 1004 -- DWORD
  87. }
  88.  
  89. local timer_address = 0x2011377
  90. local charselect_timer_address = 0x20154FB
  91. local infinite_time = 1
  92. local pressing_C = 0 -- Infinite time button
  93. local pressing_V = 0 -- Mode Toggle
  94. local pressing_P = 0 -- Toggle Players
  95.  
  96. local Display = {
  97. P1 = {},
  98. P2 = {}
  99. }
  100. local PlayerZ = {}
  101.  
  102. -- Used in conversion function
  103.     local Division_Type = {
  104.         B = 256.0,          --BYTE
  105.         b = 256.0,          --BYTE
  106.         W = 65536,          --WORD
  107.         w = 65536,          --WORD     
  108.         D = 4294967296.0,   --DWORD
  109.         d = 4294967296.0,   --DWORD    
  110.     }
  111. --Useful Maths functions for converting floating points
  112.     function Subpixel_Floatconvert(c,x)
  113.     local Output
  114.     if x == 0 then
  115.         return 0--x = x
  116.     else
  117. --      local absx = x-- math.abs(x)
  118. --      local z = math.sign(x)
  119. --          if x < c /2 then
  120.                 Output = math.abs(x)/ c
  121. --              absx = absx / c
  122. --          else
  123. --              Output = math.abs(x - c) / c
  124. --          end
  125.         return Output + .0--absx + .0
  126.         end
  127.     end
  128.  
  129. --Weirdly it's documented as an inherent function but it isn't. FBNeo is weird i guess 
  130.     function math.sign(x)
  131.     if x<0 then
  132.         return -1
  133.         elseif x>0 then
  134.             return 1
  135.         else
  136.             return 0
  137.         end
  138.     end
  139.    
  140.     --X = Velocity, Y = Subpixel to be converted to Floating Point
  141.     --Z = Container for current velocity direction
  142.     function OutputFloat(x,y,axis)
  143. --  if x == 0 and y == 0 then
  144. --      return 0
  145. --  else
  146.     --Multiply Floating Point by Velocity value
  147. --      Output = x
  148. --      z = math.sign(x)
  149. --      y = math.abs(y)  + .0
  150. --      y = y * x
  151. --      Output = x +  y--(y * z)
  152.         if axis == 1 then --If X Axis
  153.             return x + y -- (math.abs(x) + y) * math.sign(x)
  154.         else              --If Y Axis
  155.             return (math.abs(x) + y) * math.sign(x)
  156.         end
  157. --      return Output
  158. --      end
  159.     end
  160.  
  161. local data_params = 15
  162.  
  163. while true do
  164. gui.clearuncommitted()
  165.     local keys = input.get()
  166.    
  167.     for i = 0,1,1 do
  168.    
  169.     if Current_Mode == 1 then
  170.     PlayerZ[i] = {
  171.     Current_X_Vel             = rw(Player_UID.P1 + (Space * i) +  UID_Data.vel_X),
  172.     Current_X_Vel_Subvel      = rw(Player_UID.P1 + (Space * i) +  UID_Data.vel_X_Subvel),
  173.     Current_Y_Vel             = rw(Player_UID.P1 + (Space * i) +  UID_Data.vel_Y),
  174.     Current_Y_SubVel          = rw(Player_UID.P1 + (Space * i) +  UID_Data.subvel_Y)    ,
  175.     Current_Y_Accel           = rd(Player_UID.P1 + (Space * i) +  UID_Data.accel_Y),
  176.     Current_X_Pos             = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_X),
  177.     Current_pos_X_subpixel    = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_X_subpixel),
  178.     Current_Y_Pos             = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_Y),
  179.     Current_pos_Y_subpixel    = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_Y_subpixel),
  180.     Current_Anim_Ptr          = rd(Player_UID.P1 + (Space * i) +  UID_Data.Anim_Pointer),
  181. --  Current_Animelem_Ptr      = rd(Player_UID.P1 + (Space * i) +  UID_Data.Animelem_Pointer),
  182.     Current_Sprite_Header_Ptr = rd(Player_UID.P1 + (Space * i) +  UID_Data.Sprite_Header),
  183.     Current_Internal_Spriteno = rw(Player_UID.P1 + (Space * i) +  UID_Data.Internal_Spriteno),
  184.     Current_Hitpause          = rb(Player_UID.P1 + (Space * i) +  UID_Data.Hitpause),
  185.     }
  186.     --POINTER LIST 1
  187.     for b = 0,UID_Data.Pointer_List_1.No_of_Pointers-1,1 do
  188.         Pointer_List_1CHECK = {}
  189.         Pointer_List_1CHECK[b+1] = rd(Player_UID.P1 + (Space * i) +  UID_Data.Pointer_List_1.Offset+ (4*b))
  190.         gui.text(textx3,texty*(b+1)+40, string.format("List 1-%d = 0x%x", b, Pointer_List_1CHECK[b+1]))
  191.     end
  192.     --POINTER LIST 2
  193.     for b = 0,UID_Data.Pointer_List_2.No_of_Pointers-1,1 do
  194.         Pointer_List_2CHECK = {}
  195.         Pointer_List_2CHECK[b+1] = rd(Player_UID.P1 + (Space * i) +  UID_Data.Pointer_List_2.Offset+ (4*b))
  196.         gui.text(textx3,texty*(b+1)+140, string.format("List 2-%d = 0x%x", b, Pointer_List_2CHECK[b+1]))
  197.     end
  198.     --POINTER LIST 3
  199.     for b = 0,UID_Data.Pointer_List_3.No_of_Pointers-1,1 do
  200.         Pointer_List_3CHECK = {}
  201.         Pointer_List_3CHECK[b+1] = rd(Player_UID.P1 + (Space * i) +  UID_Data.Pointer_List_3.Offset+ (4*b))
  202.         gui.text(textx3+88,texty*(b+1)+40, string.format("List 3-%d = 0x%x", b, Pointer_List_3CHECK[b+1]))
  203.     end
  204.     --POINTER LIST 4
  205.     for b = 0,UID_Data.Pointer_List_4.No_of_Pointers-1,1 do
  206.         Pointer_List_4CHECK = {}
  207.         Pointer_List_4CHECK[b+1] = rd(Player_UID.P1 + (Space * i) +  UID_Data.Pointer_List_4.Offset+ (4*b))
  208.         gui.text(textx3+88,texty*(b+1)+80, string.format("List 4-%d = 0x%x", b, Pointer_List_4CHECK[b+1]))
  209.     end
  210.     --POINTER LIST 5
  211.     for b = 0,UID_Data.Pointer_List_5.No_of_Pointers-1,1 do
  212.         Pointer_List_5CHECK = {}
  213.         Pointer_List_5CHECK[b+1] = rd(Player_UID.P1 + (Space * i) +  UID_Data.Pointer_List_5.Offset+ (4*b))
  214.         gui.text(textx3+88,texty*(b+1)+140, string.format("List 5-%d = 0x%x", b, Pointer_List_5CHECK[b+1]))
  215.     end
  216.    
  217. --  POS X
  218.     gui.text(text.x,text.y, "Pos X =")
  219.     gui.text(text.x2,text.y, string.format("0x%x", PlayerZ[Current_Player].Current_X_Pos)) 
  220. --  VEL X
  221.     gui.text(text.x2+30,text.y, "Vel X =")
  222.     gui.text(text.x2+65,text.y, string.format("0x%x", PlayerZ[Current_Player].Current_X_Vel))
  223. --  POS Y
  224.     gui.text(text.x,text.y*2,"Pos Y =")
  225.     gui.text(text.x2,text.y*2, string.format("0x%x", PlayerZ[Current_Player].Current_Y_Pos))
  226. --  VEL Y
  227.     gui.text(text.x2+30,text.y*2,"Vel Y =")
  228.     gui.text(text.x2+65,text.y*2, string.format("0x%x", PlayerZ[Current_Player].Current_Y_Vel))
  229. --  SUBVEL Y
  230.     gui.text(text.x2+93,text.y*2,"Subvel Y =")
  231.     gui.text(text.x2+137,text.y*2, string.format("0x%x", PlayerZ[Current_Player].Current_Y_SubVel))
  232. --  ACCEL Y
  233.     gui.text(text.x2+158,text.y*2,"Accel Y =")
  234.     gui.text(text.x2+197,text.y*2, string.format("0x%x", PlayerZ[Current_Player].Current_Y_Accel))
  235. --  ANIM POINTER
  236.     gui.text(text.x,text.y*3, "Anim Ptr =")
  237.     gui.text(text.x2+10,text.y*3, string.format("0x%x", PlayerZ[Current_Player].Current_Anim_Ptr))
  238. --  SPRITE HEADER POINTER
  239.     gui.text(text.x,text.y*4, "Sprite Header Ptr =")
  240.     gui.text(text.x2+40,text.y*4, string.format("0x%x", PlayerZ[Current_Player].Current_Sprite_Header_Ptr))
  241. --  INTERNAL SPRITENO
  242.     gui.text(text.x2+79,text.y*4, "Internal Spriteno =")
  243.     gui.text(text.x2+160,text.y*4, string.format("0x%x", PlayerZ[Current_Player].Current_Internal_Spriteno))
  244. --  HITPAUSE
  245.     gui.text(text.x,text.y*5, string.format("Hitpause = 0x%x", PlayerZ[Current_Player].Current_Hitpause))  
  246.     else
  247.    
  248.     --DISPLAY MUGEN DAYA
  249.     PlayerZ[i] = {
  250.     Current_X_Vel             = rws(Player_UID.P1 + (Space * i) +  UID_Data.vel_X),
  251.     Current_X_Vel_Subvel      = rw(Player_UID.P1 + (Space * i) +  UID_Data.vel_X_Subvel),
  252.     Current_Y_Vel             = rws(Player_UID.P1 + (Space * i) +  UID_Data.vel_Y),
  253.     Current_Y_SubVel          = rw(Player_UID.P1 + (Space * i) +  UID_Data.subvel_Y)    ,
  254.     Current_Y_Accel           = rds(Player_UID.P1 + (Space * i) +  UID_Data.accel_Y),
  255.     Current_X_Pos             = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_X),
  256.     Current_pos_X_subpixel    = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_X_subpixel),
  257.     Current_Y_Pos             = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_Y),
  258.     Current_pos_Y_subpixel    = rw(Player_UID.P1 + (Space * i) +  UID_Data.pos_Y_subpixel),
  259.     Current_Anim_Ptr          = rd(Player_UID.P1 + (Space * i) +  UID_Data.Anim_Pointer),
  260. --  Current_Animelem_Ptr      = rd(Player_UID.P1 + (Space * i) +  UID_Data.Animelem_Pointer),
  261.     Current_Sprite_Header_Ptr = rd(Player_UID.P1 + (Space * i) +  UID_Data.Sprite_Header),
  262.     Current_Internal_Spriteno = rw(Player_UID.P1 + (Space * i) +  UID_Data.Internal_Spriteno),
  263.     Current_Hitpause          = rbs(Player_UID.P1 + (Space * i) +  UID_Data.Hitpause),
  264.     }
  265.  
  266.     PlayerZ[i].Current_pos_X_subpixel = Subpixel_Floatconvert(Division_Type.W,PlayerZ[i].Current_pos_X_subpixel)
  267.     PlayerZ[i].Current_X_Vel_Subvel   = Subpixel_Floatconvert(Division_Type.W,PlayerZ[i].Current_X_Vel_Subvel)         
  268.     PlayerZ[i].Current_pos_Y_subpixel = Subpixel_Floatconvert(Division_Type.W,PlayerZ[i].Current_pos_Y_subpixel)
  269.     PlayerZ[i].Current_Y_SubVel       = Subpixel_Floatconvert(Division_Type.W,PlayerZ[i].Current_Y_SubVel)
  270.     PlayerZ[i].Current_Y_Accel        = Subpixel_Floatconvert(Division_Type.W,PlayerZ[i].Current_Y_Accel)
  271.  
  272.  
  273. --  POS X
  274. --  gui.text(text.x,text.y, "Pos X =")
  275. --  gui.text(text.x2,text.y, string.format("%d", PlayerZ[Current_Player].Current_X_Pos))   
  276.     gui.text(text.x,text.y, string.format("Pos X = %f", OutputFloat(PlayerZ[Current_Player].Current_X_Pos,PlayerZ[Current_Player].Current_pos_X_subpixel,1)))
  277. --  VEL X
  278. --  gui.text(text.x2+30,text.y, "Vel X =")
  279. --  gui.text(text.x2+52,text.y, string.format("Vel X = %f", PlayerZ[Current_Player].Current_X_Vel))
  280.     gui.text(text.x2+52,text.y, string.format("Vel X = %f", OutputFloat(PlayerZ[Current_Player].Current_X_Vel,PlayerZ[Current_Player].Current_X_Vel_Subvel,1)))
  281. --  POS Y
  282. --  gui.text(text.x,text.y*2,"Pos Y =")
  283. --  gui.text(text.x2,text.y*2, string.format("%d", PlayerZ[Current_Player].Current_Y_Pos))
  284.     gui.text(text.x,text.y*2, string.format("Pos Y = %f", OutputFloat(PlayerZ[Current_Player].Current_Y_Pos,PlayerZ[Current_Player].Current_pos_Y_subpixel,2)))
  285. --  VEL Y
  286. --  gui.text(text.x2+60,text.y*2,"Vel Y =")
  287.     gui.text(text.x2+52,text.y*2, string.format("Vel Y = %f", OutputFloat(PlayerZ[Current_Player].Current_Y_Vel,PlayerZ[Current_Player].Current_Y_SubVel,2)))
  288. --  ACCEL Y
  289. --  gui.text(text.x2+168,text.y*2,"Accel Y =")
  290.     gui.text(text.x2+142,text.y*2, string.format("Accel Y = %f", PlayerZ[Current_Player].Current_Y_Accel))
  291. --  ANIM POINTER
  292.     gui.text(text.x,text.y*3, "Anim Ptr =")
  293.     gui.text(text.x2+10,text.y*3, string.format("0x%x", PlayerZ[Current_Player].Current_Anim_Ptr))
  294. --  SPRITE HEADER POINTER
  295.     gui.text(text.x,text.y*4, "Sprite Header Ptr =")
  296.     gui.text(text.x2+40,text.y*4, string.format("0x%x", PlayerZ[Current_Player].Current_Sprite_Header_Ptr))
  297. --  INTERNAL SPRITENO
  298.     gui.text(text.x2+79,text.y*4, "Internal Spriteno =")
  299.     gui.text(text.x2+160,text.y*4, string.format("0x%x", PlayerZ[Current_Player].Current_Internal_Spriteno))
  300. --  HITPAUSE
  301.     gui.text(text.x,text.y*5, string.format("Hitpause = %d", PlayerZ[Current_Player].Current_Hitpause))
  302.     end
  303.    
  304.         --Freeze timer.cancel()
  305.     if infinite_time == 1 then
  306.         ww(timer_address, rw(timer_address)+1)
  307.         wb(charselect_timer_address, 0x99)
  308.         else
  309.         ww(timer_address,0)
  310.         wb(charselect_timer_address, 0)
  311. --      memory.writedword(P1_Characterselect_cursor_adr,0X0000170E)
  312.     end
  313.    
  314.             --Infinite Time Toggle
  315.     if keys.C and pressing_C == 0 then
  316.         if infinite_time == 1 then
  317.             infinite_time = 0
  318.             pressing_C = 1
  319.         else
  320.             infinite_time = 1
  321.             pressing_C = 1
  322.     end
  323. end
  324.    
  325.     if pressing_C == 1 and not keys.C then
  326.             pressing_C = 0
  327.     end
  328.    
  329.     --` TOGGLE MODE
  330.     if Current_Mode == 1 then
  331.     gui.text(text.x+240,text.y*20, "V - Data Mode - CPS3")
  332.     else
  333.     gui.text(text.x+240,text.y*20, "V - Data Mode - MUGEN")
  334.     end
  335.     --` INFINITE TIME
  336.     gui.text(text.x+140,text.y*20, "C - Infinite Time = ".. infinite_time)
  337.     --` TOGGLE PLAYER
  338.     gui.text(text.x+140,text.y*21, "P - Toggle Current Player")
  339.    
  340.     --` Current Player
  341.     gui.text(0,0, "Player ".. Current_Player+1)
  342.  
  343.     --Toggle Data view
  344.     if pressing_V == 0 and keys.V then
  345.         if Current_Mode == 1 then
  346.             Current_Mode = 2
  347.             pressing_V = 1
  348.         else
  349.             Current_Mode = 1   
  350.             pressing_V = 1
  351.         end
  352.     end
  353.    
  354.     if pressing_V == 1 and not keys.V then
  355.             pressing_V = 0
  356.     end
  357.  
  358.     --Toggle Data view
  359.     if pressing_P == 0 and keys.P then
  360.         if Current_Player == 0 then
  361.             Current_Player = 1
  362.             pressing_P = 1
  363.         else
  364.             Current_Player = 0
  365.             pressing_P = 1
  366.         end
  367.     end
  368.    
  369.     if pressing_P == 1 and not keys.P then
  370.             pressing_P = 0
  371.     end
  372.    
  373. end
  374.     emu.frameadvance()
  375. end
RAW Paste Data Copied