help with 8x8 Matrix code

hello i was woundering if someone can help me modify this code to work with an 8x8 matrix.

/*
 * Show animations on a DIMxDIM led matrix
 *
 * Uses Timer1 library to
 * constantly run an interrupt routine
 * at a specified frequency. This
 * refreshes the display without the
 * main loop having to do anything.
 *
 */
#include <TimerOne.h>

//#define TESTMODE // continuously sequence thru the LED's 

#define DIM 5 // x/y dimension - 5x5 matrix
#define DIM1 (DIM-1)

typedef byte Frame[DIM];

#include "frames.h"

byte row = 0;
byte *curFrame;
int curFrameIdx;

// col[xx] of leds - anodes
// these are the arduino pins assigned to each column
int cols[DIM] = {37,36,35,34,33};

// row[xx] of leds - cathodes
// these are the arduino pins assigned to each row
int rows[DIM] = {7,6,5,4,3};

Frame blankFrame =
{B00000,
 B00000,
 B00000,
 B00000,
 B00000};

// blank the screen
void clearLeds() {
  // blank screen
  curFrame = blankFrame;
}

// select a frame to display
// idx = 0 -> FRAMDECNT-1
void setFrame(int idx) {
  curFrame = Frames[idx];
}

// Interrupt routine
// each time display() is called, it turns off the previous row
// and turns on the next row
byte bitMask = B00000011;
void display() {
  digitalWrite(rows[row], HIGH);  // Turn whole previous row off

  if (bitMask == B00010000) {
    bitMask = B00000011;  // light the right 2 columns (pins 9,8)
    // increment row and wrap if necessary
    if (++row == DIM) {
      row = 0;
    }
  }
  else if (bitMask == B00000011) {
    bitMask = B00001100;  // light the middle 2 columns (pins 11,10)
  }
  else { // bitMaskIdx == B00001100
    bitMask = B00010000;  // light the leftmost column (pin 12)
  }
  
  // direct port manipulation.
  // PORTB is a pseudo variable for digital pins 8 to 13 The two high bits (6 & 7) map to the crystal pins and are not usable
  // the bottom 5 bits are our columns.  We don't want to change the other bits,
  // so we first mask the bits we ignore, and then set the bits we want to light
  PORTC &= B11100000;
  PORTC |= curFrame[row] & bitMask;
  
  digitalWrite(rows[row], LOW); // Turn whole row on at once (for equal lighting times)
}


void setup() {
  int i;
  
  // sets the pins as output
  for (i = 0; i < DIM; i++) {
    pinMode(cols[i], OUTPUT);
    pinMode(rows[i], OUTPUT);
  }

  // set up cols and rows (set display to dark)
  for (i = 0; i < DIM; i++) {
    digitalWrite(cols[i], LOW);
  }

  for (i = 0; i < DIM; i++) {
    digitalWrite(rows[i], HIGH);
  }


  clearLeds();
  
#ifdef TESTMODE  
  while (1) {
  for (i=0;i < DIM;i++) {
    digitalWrite(rows[i],LOW);
    for (int j=0;j < DIM;j++) {
      digitalWrite(cols[j],HIGH);
      delay(250);
      digitalWrite(cols[j],LOW);
    }
    digitalWrite(rows[i],HIGH);
  }
  }
#else // !TESTMODE
  // interrupt interval in uSec
  // this determines how long to keep each row turned on
  // so if we have 5 rows, we redraw the whole screen
  // once every 5 rows * 3 cycles per row * 1000 usec = .015 sec -> 66.67Hz
  // if you perceive flickering you can decrease to 500 for a 133.33Hz rate
  Timer1.initialize(1000);
  
  Timer1.attachInterrupt(display); // ISR

  curFrameIdx = -1;
#endif // TESTMODE
                                                 
}

void loop() {
  // increment the frame index and wrap if necessary
  if (++curFrameIdx == FRAMECNT) {
    curFrameIdx = 0;
  }

  // select frame for display
  setFrame(curFrameIdx);

  delay(400); // wait time between frames in ms
}

Change the value of DIM to 8.

Anywhere there is an array of size 5, make it an array of size 8.

Anywhere there is a value that is 5 bits long, make it 8 bits.

Seeing as how that code uses direct port manipulation, you'll need to make sure that all the pins used are on the same port.

i tried changing DIM 8 but i may have been useing the wrong pins. i am using arduino mega. what pins are on what ports. thanks.

// these are the arduino pins assigned to each column
int cols[DIM] = {37,36,35,34,33}; <<<<----- add 3 more pins here

// row[xx] of leds - cathodes
// these are the arduino pins assigned to each row
int rows[DIM] = {7,6,5,4,3}; <<<<----- add 3 more pins and here

i cant just add any pin. they have to be of the same port.
and i dont know what pins it is

The port-numbers of the atmega2560 controller can be found in the data-sheet, http://www.atmel.com/dyn/resources/prod_documents/doc2549.pdf, page two shows a lay-out of the chip with pin/port-numbers.

With the schematics it's possible to determine which ports are available on which pins http://arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf. Just had a look and have not worked with the 2560 yet, all pins of ports A, B, C, F, K and L seem available on arduinos headers, pins of other ports are available partly.

thanks for all the help. i have figured it out.