But the problem here is that it's written for the AtMega168 instead of the Atmega1280, and i have no idea on how to adjust it to work with my arduino mega, suggestions anyone?
The good news is that the 1280 is pretty much back-compatible, so the direct hardware access stuff ought to work. HOWEVER... it is important to note is that the Arduino pin-assignments are completely different between the standard Arduino and the Mega. Thus the Arduino numbers for PWM pins will need changing - you have 5 or 6 timers to choose between too.
The best documentation for this is in the Arduino environment itself: Look in this file (within your Arduino folder)