What is this StandardFirmata_ModifiedAll code doing?

the reason I would like to understand the code is because my arduino not UNO but I am using MEGA...

Then you have a relatively major job ahead of you, and you will most definitely need to understand the code. The reason for this is that Firmata currently does not play well with the Mega (which has lot more pins, including more PWM pins, more analog pins) and more timers supporting more servos - none of which Firmata knows about.

No one from the Firmata community seems interested in improving Firmata to work with the Mega, so thank you for volunteering.

Hmm, could you explain explicitly what you mean with dumb device?

I mean that with the Firmata sketch uploaded, the functionality of the Arduino is fixed. It is limited by what the program on the other end tells it to do (read a digital pin, write to a digital pin, read an analog pin, etc.).

It can not also, for instance, run a web server or do timer related things or respond to external interrupts.

Why no need to understand the sketch?

As far as your original intent, modifying a GUI on a PC, there is no need to understand exactly how the Arduino responds to a Firmata-formatted request to read a digital pin or set a PWM value or read an analog pin. All you need to know is that it does.