.hack//Fragment Patcher

.hack//Fragment Patcher is a homebrew application for the PS2 and the emulator PCSX2 that will allow the user to play the game in english without the need to download a modified copy of the game. With this anyone with a copy of the original game can pop it into their ps2 (or PC through the emulator), run the homebrew and play.

The patch is in development and currently has the following features:

  • DNAS Bypass and able to connect to Alkalime’s Lobby Server
  • Basic ground work for translations (Currently only Chaos gate is translated)
  • EXP Loss on death for Mulitplayer has been disabled.
  • Item loss from not saving before quitting has been disabled.

I made the code open source so anyone can read through it. I am still rather new to PS2 homebrew development so if the code doesn’t look that great, that’s because it’s probably not.
The code can be found on my github here.

Once I have a majority of the translations in place, I will make a binary release here.

.hack//fragment Patcher

 

 

 

 

Socom 2 Data exporter [PCSX2]

Socom 2 Data exporter will export the current in game data to 2 text files.

The following data is exported:

Seals Rounds Won
Terrorists Rounds Won
Total Rounds Played
Seals Alive
Terrorists Alive

You can then take the text files and add them as overlays in OBS or any streaming software that supports reading in from text files. The information is updated every 10 seconds.

Download

Socom_Reader_MainWindow

Socom2_Reader_OBSOverlay

Setting up PCSX2 for Socom 2 and Xlink Kai

Why should I use PCSX2 over a Playstation 2?

Well if you already have a PS2 setup and you don’t care about better looking visuals then PCSX2 really isn’t for you. However if you don’t wish to use a PS2 anymore or can’t be bothered but would like to play Socom2 again this this would be for you. You can expect a cleaner looking game, smoother visuals and the ability to easily use custom patches / content (Harry62’s r0005 patch for instance).

pcsx2_dgseal

pcsx2_dg

pcsx2_deathTrap

Updates

The following has updated:

  • Uploaded a new pcsx2.zip file because I forgot to include the memory card. If you download it again all you need to do is take the socomCard.ps2 from the memory cards folder and add it into your memorycards folder in your pcsx2 folder.
  • Added a trouble shooting section with some known fixes from the community that have had some issues.
  • Added instructions on installing the HDD map packs.

Continue reading “Setting up PCSX2 for Socom 2 and Xlink Kai”

Ps2Dis: Extending and relocating a string

Programs and files needed:

PS2dis
Any Hex editor. In this example I am using HxD though.
HACK_00.ELF (This is found on your .hack.//Fragment disk.) (This is also the online ELF for the game, the single player version is HACK_01.ELF

Optional

Socom 2 Imposter Maker by Dark Killer ( I used this to convert text to hexadecimal. It’s not needed but it makes it quicker.)

Problem

When translating this game from Japanese to English you tend to run into space constraints when dealing with how many letters you can cram in a memory location.  The problem came up where a translation wasn’t correct and since there just wasn’t room to actually have the correct text it instead was made to be something else. As a quick example the Twinblade spell “Tiger Claws” is currently just “Claws”.

A way to fix this issue

In the game .hack//fragment strings are loaded in by pointers.
For this example I am going to show how we can extend a string past the limit it currently has.
Currently I have a level 15 Blademaster that knows the spell Vak Slash and I want to call it something else, something longer.

So we open up PS2Dis and take the HACK_00.ELF and drag it over to PS2Dis. Press Control G and type the following “Vak Slash”, you should see something like this:
ps2Dis Label List

Continue reading “Ps2Dis: Extending and relocating a string”

MSSQL Sub Query

This is written using Microsoft SQL Server however a lot of this can carry over just fine to other SQL variants with little change. I am also using SQL Management Studio 2016 when writing this query. This can be found here.

Sub queries come handy when you need to return data from multiple tables but need that data Summed up or some form of calculation done on them. This isn’t the only scenario where these are useful but in this example that’s what I will be doing.

The example below does not require you to create any tables as everything is done in memory.

Creating our tables:

DECLARE @Users TABLE (
	UserID INT IDENTITY(1,1) PRIMARY KEY, 
	FirstName VARCHAR(25), 
	LastName VARCHAR(25)
 
); 
 
DECLARE @items TABLE (
	ItemID INT IDENTITY(1,1) PRIMARY KEY, 
	ItemName VARCHAR(150), 
	PricePerUnit NUMERIC(5,2)
 
); 
 
DECLARE @sales TABLE (
	SaleID INT IDENTITY(1,1) PRIMARY KEY,
	UserID INT, 
	ItemID INT, 
	AmountSold INT
 
);

 

The “@” tells SQL Server that we are creating a variable and in this case the data type for that variable is a table.

Notes:
IDENTITY(1,1) means that this field auto increments. This is great for Primary keys so you do not have to know what the last ID was, it will do that for you and insert it.

Now we want to insert data into these table so we have something to lookup later on.

Insert statements:

Continue reading “MSSQL Sub Query”

Wallpaper-Changer (source code)

This version of the wallpaper changer is based on my original code that was written in VB.NET. I chose to re-write this program mainly because the original code was horrible and I’ve been wanting to move a lot of my older programs over to C#.

The main purpose for this program was to be used in windows XP since this wasn’t a feature that it had. It never really worked in a way that I wanted it to (originally) so this re-write corrects a lot of the issues that the original had. I decided to post it on github with the hopes that someone may find it useful in some way.

The code as is isn’t complete. There are some changes I plan on making (currently it just does jpgs) but as the code is , it works.

The code can be found below:

Wallpaper-Changer Github

Sys Clock (Source Code)

Sys Clock is a simple program I wrote to show the current day of the week, Time, and full date. I came up with the idea for this while playing a game that did not display what time it currently was. Since I played in full screen windowed, an always on top program worked perfectly for this situation. The window for the program can either be locked in place or moved around based on user input.

Sys Clock

 

Source Code can be found on my github.

C# Allow only 1 instance of a form to be opened

While working on some programs dealing with multiple forms, I ran into an issue where I would end up with more than 1 instance of the same form being created. This came up when using a form as an MDI parent and then trying to open another form as a child to the parent form. When the child form would open, you could continue opening new instances of that same form while the one prior was still opened.

The code below will check to see if it already exists and if it doesn’t assign the new form as a child to the mdi parent form and open it.

 

//Code that handles Child forms. May be adding more code to this down the road for customization.
        //No need to write the same code for every form
        private void CreateMDIChild(Form childForm)
        {
            //Checks if child form already exists. Only open if it does not exist in the collection
            FormCollection allForms = Application.OpenForms;
            bool formOpened = false; //Assume that this form does not already exist
 
            foreach (Form frm in allForms)
            {
                if (frm.Name == childForm.Name)
                {
                    //Tried to open form here however it throws an error about the collection being modified. So we create a bool and if the form exists
                    //set it to true
                    formOpened = true;
                }
            }
            //As long as formOpened is false we can open the new form as a child form to the parent
            if (formOpened == false)
            {
                childForm.MdiParent = this;
                childForm.Show();
            }
        }

Using the method

private void loginRegisterToolStripMenuItem_Click(object sender, EventArgs e)
        {    
            CreateMDIChild(new frm_LoginRegister());
        }

Reflector Preventer

reflectorPreventer

This program makes it harder for someone to decompile your program with reflector.
How to use:
Select your .net compiled program and click patch.
To make it so you are able to open the binary with reflector simply select the file and click “Restore File”

This program may throw false positives with some anti virus software.

 

Download

[ASP.NET /VB.NET] Populate a Datagrid view without a database

I wanted to list out some data for a page that wasn’t being pulled from a database but I didn’t want to write out the table and all that. So I dropped a datagridview on to the webpage and wrote some code in the code behind.

ASP.NET Side of things

<asp:GridView ID="grd_Specs" CssClass="footable" runat="server" AutoGenerateColumns="False">
	<Columns>      
		<asp:BoundField DataField="item1" HeaderText="Pc Specs"   />
		<asp:BoundField DataField="itemstat" HeaderText="" />
	</Columns>
</asp:GridView>

 

 

VB.Net Code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PopulatePCGrid()
 
    End Sub
 
    Dim DT As New DataTable
    Dim DR As DataRow
 
    Private Sub PopulatePCGrid()
        Dim DS As New DataSet
 
        DT = New DataTable("items")
        DT.Columns.Add("item1")
        DT.Columns.Add("itemstat")
        DR = DT.NewRow
 
        AddRowToGrid("Operating System", My.Computer.Info.OSFullName.ToString)
        DR = DT.NewRow
        AddRowToGrid("Total Memory", ((My.Computer.Info.TotalPhysicalMemory / 1024) / 1024).ToString("N0") & " MB")
 
       grd_Specs.DataSource = DT
 
       grd_Specs.DataBind()
    End Sub
 
    Private Sub AddRowToGrid(ByVal description As String, ByVal data As Object)
        With DR
            .Item("item1") = description
            .Item("itemstat") = data
        End With
        DT.Rows.Add(DR)
    End Sub

 

I will explain this as best as I can.
We create two variables, 1 for the Data Table and 1 for the Data Row.
When we get into PopulatePCGrid we create a new data set and set up the data table to match the gridview layout. If these fields do not match you will get an error on page load. So make sure the fields you want exist in both the gridview and in the code behind.

I wrote a sub proceedure to add rows to the dataTable. This isn’t required but it’s best to break out code that you will be using over and over again and make them into functions /subs.

So we call the proceedure and pass in description and data. Data is an object simply because it could be anything. I didn’t want to limit it to a string or integer because that wouldn’t be true (and in fact on the actual page I wrote this for it wasn’t true).

We then add that row to the data table and go back to PopulatePCGrid to finish the rest of the code. We create a new Datarow and then continue to add more information to the Data table. After we finish that we bind the datagridview and we end up with something like this:

datagridviewExample