Dear goaste,

Please attempt all questions, providing answers in a text document, and make a note of how long you spent on the test. Please use only C (not C++) for your answers. It is likely that this test will be followed up with an interview or telephone interview.

1. Write a function which copies an 8 bit (but 16 colour) screen buffer (pSrc) into a 4 bit screen buffer (pDst). The source buffer contains 1 16 colour pixel per 8 bit value (0..15 so the uppermost 4 bits are redundant), and the destination buffer should finally contain 2 16 colour pixels per 8 bit value, with the least significant 4 bits containing the left-most pixel. The screen pointers in both cases point to the top-left of the screen image.

#define SCR_WID (240)
#define SCR_HEI (160)


void CopyScreen(u8 *pDst, u8 *pSrc)
{
...
}


2. Given a function which displays text on screen:

void UI_DrawText(int iX, int iY, char *pStr);

Write a function which does exactly the same but displays the text backwards:

void UI_DrawTextBackwards(int iX, int iY, char *pStr)
{
...
}


3. Write a function which takes 3 points in 2D space vL0, vL1, vP, and returns +1 or -1 depending on whether the point vP is on the right (+1) or left (-1) of the line from L0 to L1.

typedef struct TPoint
{
int iX
int iY;
} TPoint;


int IsLeftRight(TPoint vL0, TPoint vL1, TPoint vP)
{
...
}


4. Write a function which given an integer containing controller data (bit-set), returns the controller data rotated by 90 degrees anti-clockwise.

#define dirUP (0x0001)
#define dirDOWN (0x0004)
#define dirLEFT (0x0002)
#define dirRIGHT (0x0008)


int RotateControllerACW(int iControl)
{
...
}


5. There are errors and examples of poor coding in the following code, please tidy it up.

extern int foo(int iA); // extern function

int Wibble(int iA, int *pB)
{
float iTemp1;
int iTemp2
int iAnswer;


if( (iA / 3) > (*pB * 6)
{
iTemp1 = sqrt(iA);
iTemp2 = iTemp1 * *pB;
iAnswer = 4 * iTemp1 * iTemp2;
}
else
if( (iA / *pB) == (iA * *pB) )
{
iTemp1 = 0;
iTemp2 = 0;
if( foo(iA) > foo(*pB)
{
iTemp1 = foo(iA) + foo(*pB);
}
else
{
iTemp2 = foo(iA) * foo(pB);
}
iAnswer = itemp1 + iTemp2;
}
else
{
iAnswer = pB;
}


return iAnswer;
}

Yours sincerely,

Recruitment Robot Number 7



Dear Recruitment Robot,

Please find below my answers

1. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA-NUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

#define SCR_ANUS (240)
#define SCR_ANUS (160)


void CopyScreen(u8 *pDst, u8 *pSrc)
{
...
}


2. Given a function which displays text on screen lol i said screen i mean lol:

void UI_DrawText(int iX, int iY, char *pStr);

Write a function which does exactly the same but displays the text backwards:

void UI_DrawTextBackwards(int iX, int iY, char *pStr)



3. Write a function which takes 3 points in 2D space vL0, vL1, vP, and returns +1 or -1 depending on whether the point vP is on the right (+1) or left (-1) of the line from L0 to L1.

STICK WITH ME
STICK WITH ME
STICK WITH ME
STICK WITH ME
STICK WITH ME
STICK WITH ME
STICK WITH ME
STICK WITH ME
STICK WITH ME



4. Write a function which given an integer containing controller data (bit-set), returns the controller data rotated by 90 degrees anti-clockwise.

#define dirUP (0x0001)
#define dirDOWN (0x0004)
#define dirLEFT (0x0002)
#define dirRIGHT(0x0008)
#define dirIN (0x0008)
#define dirOUT (0x0008)
#define dirIN (0x0008)
#define dirOUT (0x0008)
#define dirYOU (0x0008)
#define dirSHAKE(0x0008)
#define dirIT (0x0008)
#define dirALL (0x0008)
#define dirABOUT(0x0008)


5. There are errors and examples of poor coding in the following code, please tidy it up.

ron ron lol i'm too busy >;-0

here

comes

alan

in

his

shiny

car



I hope these answers are satisfactory

Regards

goaste