Task 1: Refactor existing code

First task towards completion of the GSoC project was to refactor existing code such that it can be used later in the project.

Originally, GNOME-Games handled firmware checks directly through the retro core source. While refactoring, GNOME Games’ model of individual modules must be kept in mind. But firmware are predominantly used by retro consoles (libretro) such as Game Boy Advance, Famicom Entertainment System, Super NES etc. So, to not break the model an abstract was needed such that retro consoles are able to use the refactored code easily, keeping the new code generic such that it theoretically works for any given platform.

To achieve this, a Core interface was made with abstract functions which will be used by the check sum code. But since Core is an interface, it can not have function bodies. Which is why a subclass called RetroCore was also made, which defines all the abstract prototypes defined in Core that will be used by retro platform.

The reason an abstract was needed in the first place was because of the fact that a Retro.CoreDescriptor object is needed to conduct check sums of firmware. But because it’s a Retro class function, it will be against GNOME Games programming model. Hence the need for Core interface. Which is intended as a wrapper for Retro.CoreDescriptor. These wrappers are then defined in RetroCore and used when needed.

After RetroCore was made, the next step was to make a class that conducts the check sums, which was pretty simple as most of the code that had that functionality already existed. This class was named FirmwareManager and has two functions. One conducts the check sums, and the other one passes the necessary information to that function on per-firmware basis to the check sum function, as a single platform can have multiple firmware.

Later a Core object and a FirmwareManager object were defined in retro core source class, and all the the existing code was removed while implementing the new refactored code successfully.

I’m very thankful to my mentor Alexander Mikhaylenko (@exalm/@alexm) for putting up with me and repeatedly explaining what needed to be done, how it can be done and repeatedly reviewing my merge request.

Next objective is to make a Firmware object. Let’s not get lazy and keep working!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website at WordPress.com
Get started
%d bloggers like this: