Yes, you will have to change the code to match the Mega pinout.
Because the program need to run quite fast, and the Arduino functions
digitalRead()
and digitalWrite()
are dead slow, the author of the
program used direct port access for performing the raw IO.
For example:
//Wait for vsync it is on pin 3 (counting from 0) portD
while(!(PIND&8));//wait for high
while((PIND&8));//wait for low
This is testing pin PD3 (8 is 23), which on the Uno is
digital 3, but on the Mega is digital 18. The same code could
be written in a portable fashion:
//Wait for vsync it is on pin 3 (counting from 0) portD
while (digitalRead(3) == LOW); //wait for high
while (digitalRead(3) == HIGH); //wait for low
but it would probably be too slow.
Note also that here:
UDR0=(PINC&15)|(PIND&240);
the program takes advantage of the particular pin mapping of the Uno in
order to read 8 inputs with only two port reads (4 bits on
port C and 4 bits on port D). You could do even better on the Mega
if you use pins A8 through A15 for the data bus, and then read the whole
8-bit word as PINK
.
There may be some other differences between the Uno and the Mega that
need to be taken into account, but the pin mapping is the only one that
is obvious to me just by quickly going through the code.