John icon

F# Menu Base

John | PRO | 09/18/15 02:08:49 AM UTC | 0 ⭐ | 11092 👁️ | Never ⏰ | []
F# |

4.47 KB

|

None

|

0 👍

/

0 👎

open System
open System.Threading
open PS3Lib
 
let PS3 = PS3Lib.PS3API(SelectAPI.TargetManager)
let mutable AlreadyConnected = false
let Connect() =
    let mutable attached = false
    if(PS3.ConnectTarget()) 
     then (attached <- PS3.AttachProcess())
    if(attached) then true
    else false
 
let tryConnectAttach() = 
    if(Connect()) 
     then 
      printfn "Connected and attached successfully"
      AlreadyConnected <- true 
      true
    else 
     printfn "Failed to Connect and/or Attach"
     false
 
let NotificationText = 0x02056B04u
let NotificationState = 0x02057214u + 0x03u
let ButtonsMonitoring = 0x01FC7C88u + 0x08u
type ModMenu = 
     struct
      val mutable isOpen: bool
      val mutable CurrentOption: int
     end
 
let getButton() = 
    PS3.Extension.ReadUInt32(ButtonsMonitoring)
 
let ShowText(show) =
    let mutable State = 0x02uy
    if(show) then State <- 0x03uy
    PS3.Extension.WriteByte(NotificationState, State)
 
let ChangeText(text) =
    PS3.Extension.WriteString(NotificationText, text)
 
let AppendStringArray(text) = 
    let mutable Output = ""
    for _string in text 
     do Output <- Output + _string + "\n"
    Output
 
let DrawMenu(text, option) = 
    let mutable Output = ""
    let SelectedColor = "~r~"
    let White = "~w~"
    let mutable Color = White
    let mutable Index : int = 0
    for _string in text 
     do
      if(option = Index) then Color <- SelectedColor
      else Color <- White
      Output <- Output + Color + _string +  "~n~"
      Index <- (Index + 1)
    ChangeText(Output)
    ShowText(true)
 
let doGodmode() =
    let bytes = [| 0x38uy; 0x60uy; 0x7Fuy; 0xFFuy; 0xB0uy; 0x7Fuy; 0x00uy; 0xB4uy; |]
    PS3.SetMemory(0x1185D08u, bytes)
 
let doSuperJump() =
    let bytes = [| 0x60uy; 0x00uy; 0x00uy; 0x00uy; |]
    PS3.SetMemory(0x5EE6A0u, bytes)
 
let doUnlimitedAmmo() =
    let bytes1 = [| 0x3Buy; 0xA0uy; 0x03uy; 0xE7uy; |]
    let bytes2 = [| 0x38uy; 0xE0uy; 0x00uy; 0x63uy; |]
    PS3.SetMemory(0xFBF0A4u, bytes1)
    PS3.SetMemory(0xFDA420u, bytes2)
    
 
let selectOption(option) = 
    match option with 
     | 0 -> doGodmode(); printfn "Enabled Godmode"              //do something when option 0 is selected
     | 1 -> doSuperJump(); printfn "Enabled Super Jump"         //do something when option 1 is selected
     | 2 -> doUnlimitedAmmo(); printfn "Enabled Unlimited Ammo"  //do something when option 2 is selected
     | 3 -> printfn "Option 3"                                  //do something when option 3 is selected
     | 4 -> printfn "Option 4"                                  //do something when option 4 is selected, etc.
     | _ -> ()                                                  //do nothing when no option is selected
    printfn "Selected Option %i" option
 
let Monitor() =
    PS3.ConnectTarget() |> ignore
    printfn "Running Menu"
    let mutable Menu : ModMenu = new ModMenu()
    Menu.isOpen <- false
    Menu.CurrentOption <- 0
    ShowText(false)
 
    let MenuText = [| "God Mode"; "Super Jump"; "Unlimited Ammo"; "Option 3"; "Option 4"; "Option 5"; "Option 6" |]
 
    while true do
     if (Menu.isOpen) then 
      DrawMenu(MenuText, Menu.CurrentOption)
      match getButton() with
       | 0x00100000u -> if(Menu.CurrentOption > 0) then Menu.CurrentOption <- Menu.CurrentOption - 1                    //Dpad_up
       | 0x00400000u -> if(Menu.CurrentOption < MenuText.Length - 1) then Menu.CurrentOption <- Menu.CurrentOption + 1  //Dpad_down
       | 0x00000040u -> selectOption(Menu.CurrentOption)                                                                //Button_A
       | 0x00000080u -> Menu.isOpen <- false; ShowText(false)                                                           //Button_X
       | _ -> ()
 
     else if (getButton() = 0x00100000u) then Menu.isOpen <- true
     Thread.Sleep(100)
 
let main() =
    printfn "type 'connect' to connect to PS3"
    printfn "Type 'start' to run the menu"
    printfn "Type 'clear' to clear the console"
    printfn "Type 'exit' to exit the application"
 
    let mutable MonitorThread = new Thread(Monitor);
    while true do
     match Console.ReadLine() with
      | "connect" -> tryConnectAttach() |> ignore
      | "exit" -> Environment.Exit(0)
      | "start" ->  if(AlreadyConnected) then MonitorThread.Start() else printfn "You must connect first!"
      | "clear" -> Console.Clear()
      | _ -> printfn "Unknown command!"
 
main()
Console.ReadLine() |> ignore

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎