Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <nds.h>
- #include <stdio.h>
- void drawHline(int y, int x0, int x1, unsigned int color);
- void drawVline(int x, int y0, int y1, unsigned int color);
- void drawPlot(int x, int y, unsigned int color);
- void drawRect(int x, int y, int w, int h, unsigned int color);
- void drawFillRect(int x, int y, int w, int h, unsigned int color);
- int main(void){
- int i;
- consoleDemoInit();
- videoSetMode(MODE_FB0);
- vramSetBankA(VRAM_A_LCD);
- printf("Basic draw functions by xerpi!\n");
- for(i = 0; i < 256 * 192; i++)
- VRAM_A[i] = RGB15(31,0,0);
- drawRect( 10, 10, 20, 80, RGB15(0, 31, 0));
- drawFillRect( 100, 100, 50, 30, RGB15(0, 0, 31));
- while(1){
- swiWaitForVBlank();
- }
- return 0;
- }
- void drawPlot(int x, int y, unsigned int color){
- VRAM_A[x + y*256] = color;
- }
- void drawHline(int y, int x0, int x1, unsigned int color){
- int i;
- if(x0 < x1)
- for(i = x0; i < x1; i++)
- VRAM_A[i + y*256] = color;
- else
- for(i = x1; i < x0; i++)
- VRAM_A[i + y*256] = color;
- }
- void drawVline(int x, int y0, int y1, unsigned int color){
- int i;
- if(y0 < y1)
- for(i = y0; i < y1; i++)
- VRAM_A[x + i*256] = color;
- else
- for(i = y1; i < y0; i++)
- VRAM_A[x + i*256] = color;
- }
- void drawRect(int x, int y, int w, int h, unsigned int color){
- drawVline(x, y, y + h, color);
- drawVline(x + w, y, y + h, color);
- drawHline(y + h, x, x + w, color);
- drawHline(y, x, x + w, color);
- }
- void drawFillRect(int x, int y, int w, int h, unsigned int color){
- int i;
- for(i = y; i < y + h; i++)
- drawHline(i, x, x + w, color);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement