What does this bit do?

Post Reply
Roroy
Posts: 17
Joined: Sat Sep 22, 2012 7:00 am

What does this bit do?

Post by Roroy » Sun Sep 30, 2012 8:04 am

Code: Select all

// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
After the xfb, the 2 numbers, 20, 20.

Tried changing values, no visible results. Anyone know?
And one more thing, I know it says that this line initialises the console and everything but can someone explain in it more detail.

Thanks and cheers.

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: What does this bit do?

Post by elhobbs » Sun Sep 30, 2012 9:12 am

The console refers to a text console. It is where the text from printf is displayed. Without this call it if not going to display stdout. The parameters to the function describe the screen resolution and the region of the screen to print to. In particular the 20, 20 values set the start x and y values. In this case, do not print right at the edge, start 20 pixels down and 20 pixels from the left edge. If you made small changes to these values it would not be very noticeable.

Roroy
Posts: 17
Joined: Sat Sep 22, 2012 7:00 am

Re: What does this bit do?

Post by Roroy » Sun Sep 30, 2012 10:21 am

I'd also like to ask one more thing.

Regarding this line:

xfb[205 + 105] = 0;

It sets a pixel to the colour black right?

Thing is, the 2 numbers in the square brackets, is the first number the length of pixels from the left hand side of the screen and the second number being the number of pixels from the top of the screen down? And that sets that pixel to 0 which I presume is black colour?

Or does this line do something else?

Roroy
Posts: 17
Joined: Sat Sep 22, 2012 7:00 am

Re: What does this bit do?

Post by Roroy » Sun Sep 30, 2012 10:45 am

Sorry for double posting.
Forgot to add:

Tried changing 20, 20 to 320, 320, still prints text in the same position.
So code is:

Code: Select all

console_init(xfb,320,320,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

...

printf("\x1b[2;0H");
	

printf("Hello World!");

Post Reply

Who is online

Users browsing this forum: No registered users and 64 guests