Difference between revisions of "Plot"

From WikiPrizm
Jump to navigationJump to search
(Less-strange wording on inlining advice.)
Line 11: Line 11:
 
y - Specifies the y coordinate of the pixel in range of [0,215]<br />
 
y - Specifies the y coordinate of the pixel in range of [0,215]<br />
 
color - Specifies what color the plotted pixel will be. It is in RGB 565 format.
 
color - Specifies what color the plotted pixel will be. It is in RGB 565 format.
 +
 
== Notes ==
 
== Notes ==
It is recommended that this function be declared as static inline void instead of void. This function is very trivial and is not worth the function call overhead. If multiple source code files use this function instead of just copying and pasting the function in each file it is better to place this function in a header file that is shared between the source files.  
+
Given the minimal nature of this function, call overhead can easily be a non-trivial factor in obtaining reasonable performance. Marking it as <tt>static inline</tt> and declaring it in a single header file may be [[Optimization_Tips|appropriate]] to help ensure this function is inlined.
 +
 
 
== Comments ==
 
== Comments ==
 
Function written by ProgrammerNerd
 
Function written by ProgrammerNerd
 
[[Category: Useful Routines]]
 
[[Category: Useful Routines]]

Revision as of 14:18, 15 May 2014

Synopsis

Plots a point at (x,y) on the screen with a specified color

Source code

void plot(unsigned x,unsigned y,unsigned short color){
	unsigned short*s=(unsigned short*)0xA8000000;
	s+=(y*384)+x;
	*s=color;
}

Inputs

x - Specifies the x coordinate of the pixel in range of [0,383]
y - Specifies the y coordinate of the pixel in range of [0,215]
color - Specifies what color the plotted pixel will be. It is in RGB 565 format.

Notes

Given the minimal nature of this function, call overhead can easily be a non-trivial factor in obtaining reasonable performance. Marking it as static inline and declaring it in a single header file may be appropriate to help ensure this function is inlined.

Comments

Function written by ProgrammerNerd