SPI direct port manipulation equivalents

I'm trying to convert this to direct port manipulation for the ATMEGA1280 and have the following:

Arduino IDE using spi.h:

SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE3);
SPI.setClockDivider(SPI_CLOCK_DIV16); // 1mhz

This is the equivalent of direct port manipulation. Did I do it right?

        // SPI.begin();
         DDRB |= (1<<PB1);	//pinMode2(SCK, OUTPUT);
	 DDRB |= (1<<PB2);	//pinMode2(MOSI, OUTPUT);
	 DDRB |= (1<<PB0);	//pinMode2(SS, OUTPUT);
	 PORTB |= (1<<PB0); // SS HIGH
	 PORTB &= ~(1<<PB1); // SCK LOW
	 PORTB &= ~(1<<PB2); // MOSI LOW
         SPCR |= _BV(MSTR);
         SPCR |= _BV(SPE);
         //

         SPCR &= ~(_BV(DORD)); //SPI.setBitOrder(MSBFIRST);
         SPCR = (SPCR & ~SPI_MODE_MASK) | SPI_MODE3; //SPI.setDataMode(SPI_MODE3);

         SPCR = (SPCR & ~SPI_CLOCK_MASK) | (SPI_CLOCK_DIV16 & SPI_CLOCK_MASK);
         SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((SPI_CLOCK_DIV16 >> 2) & SPI_2XCLOCK_MASK); //SPI.setClockDivider(SP

Almost all of that is not needed, it only runs once in void setup, so you're not really gaining anything performance wise

The only one I use is direct control for chip select, after using pinMode (pinX, OUTPUT); in void setup.

Say PD2 is the chip select pin, and it is set High in Setup.

Then in loop:

PIND = 0b00000100; // toggle bit 2 by writing a 1 to it.
SPI.transfer(x);
PIND = 0b00000100; // toggle bit 2 by writing a 1 to it.

tho I generally do it this way just in case I lost track of what bit 2 was doing:

PORTD = PORTD & 0b11111011; // clear bit 2
SPI.transfer(x);
PORTD = PORTD | 0b00000100; // set bit 2

Mavromatis:
I'm trying to convert this to direct port manipulation for the ATMEGA1280 and have the following:

Why are you trying to do this?

Because I'm trying to create a new bootloader and I have a proof of concept running in arduino but now must convert so I can compile using gcc.

Nevermind -- I figured it out. Thanks!