home comics writing pictures archive about

2014-02-21 - Hex Editing

Hex editors are programs that allow you to modify the binary contents of a file. These editors usually represent this data as hexadecimal digits, hence the name. You can do very powerful things with hex editors but they can also break things quite spectacularly. Generally the process of editing the binary bits of a file involves a lot of trial and error because it’s hard to tell what each part represents; however, some file formats contain plain text strings which can be easily changed. That’s what I used to do

I used to be fairly involved with the G-Mod community and one of the groups in that community was The Skinners. The Skinners were people that spent their time modifying texture files. They would take an existing model and re-skin it to be something new. The Skinners had a problem though, modifying a texture doesn't create a new model it just changed the original. That was where hex editing came in. With a hex editor it was possible to make a copy of the model and then modify the copy to be unique from the original. You first had to change the model’s internal reference to point to the copy. Next you had to modify the texture paths to point to the new ones created by the Skinners.

I tried a little bit of skinning and modelling but the hex editing was what I really enjoyed. One of the draws for me was the word puzzle. With hex editors it is problematic to change the length of the file. This meant that you had to think of a way to create new path names that were unique and descriptive but with the same number of characters as the original. The other reason I enjoyed hex editing was it meant playing around with files on a very low level. Hex editing was probably the start of my path towards becoming a programmer. Playing around with the bits and bytes, changing how the computer perceived a file. It was fun.

2014-02-14 - Modelling

When I was younger I played around with modelling for a bit. I made a plane, a canyon, but what I really got into was porting models. Taking models from one game and converting them so that they could be used by another game. To port a model you need to find a way to extract the models out of the container format the first game uses and then find a program or series of programs that will allow you to get it into a format that the second game uses. It was a puzzle. You knew the start and end points but you had to figure out what lay between them.

I converted models from a few games but the two big ones were Homeworld and Aliens vs. Predator 2. They are two of my favourite games and they also happened to have interesting models. I ported all of the strike craft in Homeworld as well as all of the Turanic Raider ships. I ported a bunch of weapons from AvP2 as well as some helmets and masks. I also ported a couple alien eggs, a Chestburster, a Facehugger and an Alien. You can see some of them here. I rigged the Chestburster to have a skeleton but someone else did the Alien. All of these models were ported to the source engine and G-Mod since its sandbox nature made it really easy to spawn and use the ported models.

It's only a model
Ported Homeworld Carrier

Skeletons were actually one of the reasons I stopped porting the Homeworld models. A lot of the bigger ships (corvettes, frigates, and capital ships) have turrets and other moveable parts. To port these models properly those parts should be rigged and I never got around learning how to do that for non-humanoid models. I’d go to port some more models, remember I needed to learn how to rig the turrets, then get discouraged and stop. I had already solved the puzzle anyway.

2014-01-31 - Passing Parameters

C is an old but very influential programming language. In C there are two ways to pass parameters to functions, by value and by reference. Pass by value means the parameter passed to a function is a copy of the original value while pass by reference means the parameter is a pointer to the original value. The main difference is that pass by reference allows you to modify the original value. If the function is called with a variable passed by reference then any changes the function makes to the variable will be visible to the caller when the function returns.

Jump forward a few years to the rise of object oriented programming languages. In these languages most functions use pass by value but there’s a bit of an issue. In object oriented languages the object variable contains a reference to the object’s data and not the actual data. So when you pass an object by value the system is actually making a copy of that object’s reference. The original reference and the copied reference still point to the same data. This means that even though you are using pass by value you can still change the original variable’s data. If you had an employee object with name “A” and you passed it into a function that changes its name to “B” once that function returns the original employee object would also have the name “B”.

That is as long as you don’t change the reference. Changes to the function’s variable affect the original variable because they point to the same thing. If you change the thing the function variable is pointing to then this is no longer the case. This can happen if you create a new object or perform an action that creates a new object and assign the result to the function’s variable.

2014-01-17 - Budgeter Project part 3.5

I originally planned to do a post for each stage of the project but it turns out that when I get coding I don’t really feel like writing afterwards. They are fairly similar activities and I only have so much creative juice to go around. In the future I will likely leave the writing till long after the program is done and just put it on the writings page, separation of coding and writing.

I do want to give some updates on the project though. Part 1 was the database planning as I posted earlier and that’s never going to be done. I’ve changed it a bunch since I “finished” planning and will likely change it more. Part 2 was the DataViewer prototype application, which is mostly done. It needs a bit of clean up and re-organization but it does what it’s supposed to do. Part 3 is the program itself and that’s going along nicely. I’ve been using it for a few months and it’s been working out well. There’s a few features that I still need to add but the base functionality is there. To carry on from the last post here is a diagram of the current database structure. It has changed a fair bit.

Database map for project
Database table map

Speaking of databases, one welcome side effect of the program is that since all my transactions are in a database I can run queries against them. I wanted to know how much I’ve paid on my student loans recently and I was able to do a simple select from transactions where description like “%NSLSC%” query which game me all transactions that mention the NSLSC. It’s always nice to be able to do things easily.