#125238 - FugitivePuppeT - Thu Apr 12, 2007 8:38 am
First post, please bear with me, I'm not the greatest coder, and am just learning coding for the DS.
Anyways, my problem is that I learned how to create a simple drawing program that creates a "Rainbow" type of line wherever the stylus is used.
Then after some work, I finnaly got my first image displayed on the DS (The name of my image is "beer")
What I was attempting to do is sort of combine the two, and draw on top of the image. I think my problem is that I'm using different video modes for each example. Any help would be great. Here is the combined code.
Anyways, my problem is that I learned how to create a simple drawing program that creates a "Rainbow" type of line wherever the stylus is used.
Code: |
#include<nds.h>
#include<stdlib.h> void clear_screen(void){ unsigned short color; color = RGB15(0,0,0); int i; for(i = 0; i < 256*192; i++) VRAM_A[i] = color; } int main(void) { touchPosition touch; videoSetMode(MODE_FB0); vramSetBankA(VRAM_A_LCD); //notice we make sure the main graphics engine renders //to the lower lcd screen as it would be hard to draw if the //pixels did not show up directly benieth the pen lcdMainOnBottom(); while(1) { scanKeys(); if(keysHeld() & KEY_TOUCH) { // read the touchscreen coordinates touch=touchReadXY(); VRAM_A[touch.px + touch.py * 256] = rand(); } if(keysHeld() & KEY_A) clear_screen(); } return 0; } |
Then after some work, I finnaly got my first image displayed on the DS (The name of my image is "beer")
Code: |
// Including libnds set of defines
#include <nds.h> #include<stdlib.h> // Include basic memory functions #include <string.h> // Including our converted graphics #include "beerTiles_bin.h" #include "beerMap_bin.h" #include "beerPal_bin.h" int main() { // Powering up the DS 2D hardware REG_POWERCNT = POWER_ALL_2D; // Setting up video mode DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE; BG0_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1); // Setting VRAM Bank A for Background display VRAM_A_CR = VRAM_ENABLE | VRAM_A_MAIN_BG; // Copying the tiles to tile base 1 memcpy((void*)BG_TILE_RAM(1), beerTiles_bin, beerTiles_bin_size); // Copying the map to map base 0 memcpy((void*)BG_MAP_RAM(0), beerMap_bin, beerMap_bin_size); // Copying the palette to the palette area memcpy((void*)BG_PALETTE, beerPal_bin, beerPal_bin_size); // Infinate loop to keep the program running while(1) } |
What I was attempting to do is sort of combine the two, and draw on top of the image. I think my problem is that I'm using different video modes for each example. Any help would be great. Here is the combined code.
Code: |
// Including libnds set of defines
#include <nds.h> #include<stdlib.h> // Include basic memory functions #include <string.h> // Including our converted graphics #include "beerTiles_bin.h" #include "beerMap_bin.h" #include "beerPal_bin.h" //This function simply makes the screen white. Will replace later. void clear_screen(void){ unsigned short color; color = RGB15(0,0,0); int i; for(i = 0; i < 256*192; i++) VRAM_A[i] = color; } int main() { touchPosition touch; // Powering up the DS 2D hardware REG_POWERCNT = POWER_ALL_2D; // Setting up video mode DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE; BG0_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1); // Setting VRAM Bank A for Background display VRAM_A_CR = VRAM_ENABLE | VRAM_A_MAIN_BG; // Copying the tiles to tile base 1 memcpy((void*)BG_TILE_RAM(1), beerTiles_bin, beerTiles_bin_size); // Copying the map to map base 0 memcpy((void*)BG_MAP_RAM(0), beerMap_bin, beerMap_bin_size); // Copying the palette to the palette area memcpy((void*)BG_PALETTE, beerPal_bin, beerPal_bin_size); // Infinate loop while(1) { scanKeys(); if(keysHeld() & KEY_TOUCH) { // read the touchscreen coordinates touch=touchReadXY(); VRAM_A[touch.px + touch.py * 256] = rand(); } if(keysHeld() & KEY_L & KEY_R) clear_screen(); } return 0; } |