Difference between revisions of "Plot"

From WikiPrizm
Jump to navigationJump to search
(Less-strange wording on inlining advice.)
m (Use GetVRAMAddress not 0xA8000000)
 
Line 2: Line 2:
 
Plots a point at (x,y) on the screen with a specified color
 
Plots a point at (x,y) on the screen with a specified color
 
== Source code ==
 
== Source code ==
  <nowiki>void plot(unsigned x,unsigned y,unsigned short color){
+
  <nowiki>#include <fxcg/display.h>
unsigned short*s=(unsigned short*)0xA8000000;
+
void plot(unsigned x,unsigned y,unsigned short color){
 +
unsigned short*s=(unsigned short*) GetVRAMAddress;
 
s+=(y*384)+x;
 
s+=(y*384)+x;
 
*s=color;
 
*s=color;

Latest revision as of 06:44, 17 March 2022

Synopsis

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

Source code

#include <fxcg/display.h>
void plot(unsigned x,unsigned y,unsigned short color){
	unsigned short*s=(unsigned short*) GetVRAMAddress;
	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