void init_pda() { // set the sub background up for text display (we could just print to one // of the main display text backgrounds just as easily videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE | DISPLAY_BG2_ACTIVE); SUB_BG2_CR = BG_BMP8_256x256 | BG_WRAP_ON | BG_BMP_BASE(4); SUB_BG3_CR = BG_BMP8_256x256 | BG_WRAP_ON; SUB_BG3_XDX = 1 << 8; SUB_BG3_XDY = 0; SUB_BG3_YDX = 0; SUB_BG3_YDY = 1 << 8; SUB_BG2_XDX = 1 << 8; SUB_BG2_XDY = 0; SUB_BG2_YDX = 0; SUB_BG2_YDY = 1 << 8; SUB_BG3_CX = 0; SUB_BG3_CY = 0; //32 << 8; SUB_BG2_CX = 0;//2000; SUB_BG2_CY = 0;//2000; //32 << 8; for(int i = 0; i < 256; ++i) BG_PALETTE_SUB[i] = ((u16*)subscreen_pal_bin)[i]; for(int i = 0; i < 256*192/2; ++i) ((u16*)BG_BMP_RAM_SUB(4))[i] = ((u16*)map_img_bin)[i]; for(int i = 0; i < 256*256/2; ++i) ((u16*)BG_BMP_RAM_SUB(0))[i] = ((u16*)realmap_img_bin)[i]; }
void init_doorminigame() { videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE | DISPLAY_BG2_ACTIVE); vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_SPRITE, //VRAM_B_MAIN_BG_0x6020000, VRAM_C_SUB_BG, VRAM_D_MAIN_BG_0x6020000); SUB_BG2_CR = BG_BMP8_256x256 | BG_BMP_BASE(4); SUB_BG3_CR = BG_BMP8_256x256; SUB_BG3_XDX = 1 << 8; SUB_BG3_XDY = 0; SUB_BG3_YDX = 0; SUB_BG3_YDY = 1 << 8; SUB_BG2_XDX = 1 << 8; SUB_BG2_XDY = 0; SUB_BG2_YDX = 0; SUB_BG2_YDY = 1 << 8; SUB_BG3_CX = 0; SUB_BG3_CY = 0; //32 << 8; SUB_BG2_CX = 0;//2000; SUB_BG2_CY = 0;//2000; //32 << 8; for(int i = 0; i < 256; ++i) BG_PALETTE_SUB[i] = ((u16*)doorbg_pal_bin)[i]; for(int i = 0; i < 256*256/2; ++i) ((u16*)BG_BMP_RAM_SUB(0))[i] = ((u16*)doorbg_img_bin)[i]; for(int i = 0; i < 256*256/2; ++i) ((u16*)BG_BMP_RAM_SUB(4))[i] = ((u16*)doorfg_img_bin)[i]; }
void Render::ChangeGUI(int index) { switch (index) { case 1: dmaCopyHalfWords(DMA_CHANNEL, gui_btn1Bitmap, (uint16 *)BG_BMP_RAM_SUB(9), gui_btn1BitmapLen); break; case 2: dmaCopyHalfWords(DMA_CHANNEL, gui_btn2Bitmap, (uint16 *)BG_BMP_RAM_SUB(9), gui_btn2BitmapLen); break; case 3: dmaCopyHalfWords(DMA_CHANNEL, gui_btn3Bitmap, (uint16 *)BG_BMP_RAM_SUB(9), gui_btn3BitmapLen); break; case 4: dmaCopyHalfWords(DMA_CHANNEL, gui_btn4Bitmap, (uint16 *)BG_BMP_RAM_SUB(9), gui_btn4BitmapLen); break; } }
void Render::DisplayBlankSub() { dmaCopyHalfWords(DMA_CHANNEL, blankBitmap, /* This variable is generated for us by * grit. */ (uint16 *)BG_BMP_RAM_SUB(9), /* Our address for sub * background 3 */ blankBitmapLen); }
void displaySplash() { dmaCopyHalfWords(DMA_CHANNEL, splashBitmap, /* This variable is generated for us by * grit. */ (uint16 *)BG_BMP_RAM_SUB(0), /* Our address for sub * background 3 */ splashBitmapLen); /* This length (in bytes) is generated * from grit. */ }
void nds_clear_prompt() { u16 *vram = (u16 *)BG_BMP_RAM_SUB(4); if (prompt_img == NULL) { return; } clear_ppm(prompt_img, MAP_COLOUR(CLR_BLACK)); draw_ppm(prompt_img, vram, 4, prompt_y, 256); }
void Hardware::init() { #ifndef USING_SDL powerOn(POWER_ALL_2D); videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); vramSetBankA(VRAM_A_MAIN_BG_0x06000000); vramSetBankB(VRAM_B_MAIN_BG_0x06020000); vramSetBankC(VRAM_C_SUB_BG); // Initialise backgrounds bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); _topBuffer = new FrameBuffer((u16*)BG_BMP_RAM(0), SCREEN_WIDTH, SCREEN_HEIGHT); _bottomBuffer = new FrameBuffer((u16*)BG_BMP_RAM_SUB(0), SCREEN_WIDTH, SCREEN_HEIGHT); #else Uint32 initflags = SDL_INIT_VIDEO; // Initialize the SDL library if (SDL_Init(initflags) < 0) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } // Set video mode _window = SDL_CreateWindow("EarthShaker", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT * 2, 0); _renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); SDL_SetRenderDrawColor(_renderer, 0, 0, 0, 255); SDL_RenderClear(_renderer); SDL_RenderPresent(_renderer); _texture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_ABGR1555, SDL_TEXTUREACCESS_STREAMING, SCREEN_WIDTH, SCREEN_HEIGHT * 2); _topBitmap = new u16[SCREEN_WIDTH * SCREEN_HEIGHT]; _bottomBitmap = new u16[SCREEN_WIDTH * SCREEN_HEIGHT]; _topBuffer = new FrameBuffer(_topBitmap, SCREEN_WIDTH, SCREEN_HEIGHT); _bottomBuffer = new FrameBuffer(_bottomBitmap, SCREEN_WIDTH, SCREEN_HEIGHT); #endif _topGfx = _topBuffer->newGraphics(); _bottomGfx = _bottomBuffer->newGraphics(); }
void nds_draw_prompt(const char *prompt) { u16 *vram = (u16 *)BG_BMP_RAM_SUB(4); if (prompt_img == NULL) { prompt_img = alloc_ppm(252, system_font->height * 2); prompt_y = 192 - system_font->height * 2; } /* Draw the prompt */ clear_ppm(prompt_img, MAP_COLOUR(CLR_BLACK)); draw_string(system_font, (char *)prompt, prompt_img, 0, 0, -1, -1); draw_ppm(prompt_img, vram, 4, prompt_y, 256); }
void init_dialog() { videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_SPRITE, //VRAM_B_MAIN_BG_0x6020000, VRAM_C_SUB_BG, VRAM_D_MAIN_BG_0x6020000); BG3_CR = BG_BMP8_256x256; SUB_BG3_CR = BG_BMP8_256x256; BG3_XDX = 1 << 8; BG3_XDY = 0; BG3_YDX = 0; BG3_YDY = 1 << 8; BG3_CX = 0; BG3_CY = 0; //32 << 8; SUB_BG3_XDX = 1 << 8; SUB_BG3_XDY = 0; SUB_BG3_YDX = 0; SUB_BG3_YDY = 1 << 8; SUB_BG3_CX = 0; SUB_BG3_CY = 0; //32 << 8; for(int i = 0; i < 256; ++i) BG_PALETTE_SUB[i] = ((u16*)dialog_subscreen_pal_bin)[i]; for(int i = 0; i < 256; ++i) BG_PALETTE[i] = ((u16*)dialog_topscreen_pal_bin)[i]; for(int i = 0; i < 256*256/2; ++i) ((u16*)BG_BMP_RAM(0))[i] = ((u16*)dialog_topscreen_img_bin)[i]; for(int i = 0; i < 256*256/2; ++i) ((u16*)BG_BMP_RAM_SUB(0))[i] = ((u16*)dialog_subscreen_img_bin)[i]; }
#include <stdio.h> #include <stdarg.h> #include "libdsmi.h" #include "dsmi_logo_ds.h" touchPosition touch; int touch_was_down = 0; int kaos_touch = 0, kaos_x = 85, kaos_y = 85, old_kaos_x = 85, old_kaos_y = 85; int slider_touch1 = 0, slider_val1 = 160, old_slider_val1 = 160; int slider_touch2 = 0, slider_val2 = 160, old_slider_val2 = 160; int slider_touch3 = 0, slider_val3 = 160, old_slider_val3 = 160; u16 *sub_vram = (u16*)BG_BMP_RAM_SUB(2); u16 *bg3vram = (u16*)BG_BMP_RAM(0); void drawKaos(){ int i; for(i=10; i <= 160; i++){ bg3vram[i + 256 * 10] = RGB15(25,25,25)|BIT(15); bg3vram[i + 256 * 160] = RGB15(25,25,25)|BIT(15); } for(i=10; i <= 160; i++){ bg3vram[10 + 256 * i] = RGB15(25,25,25)|BIT(15); bg3vram[160 + 256 * i] = RGB15(25,25,25)|BIT(15); } for(i = old_kaos_x - 1; i <= old_kaos_x + 1 ; i++){ bg3vram[ i + 256 * (old_kaos_y - 1)] = RGB15(0,0,0);
void update_pda() { if (allow_scrolling_x) SUB_BG3_CX = x<<8; else SUB_BG3_CX = 0; if (allow_scrolling_y) SUB_BG3_CY = y<<8; else SUB_BG3_CY = 0; //SUB_BG2_CX = -x; //SUB_BG2_CY = -y; if (pressed & KEY_TOUCH) { const u8* picture = 0; const u8* subpicture = 0; if (touch.px < 48) { if (touch.py < 48) { picture = map_img_bin; subpicture = submap_img_bin; allow_scrolling_x = true; allow_scrolling_y = true; } else if (touch.py >= 48 && touch.py < 48*2) { picture = health_img_bin; subpicture = subhealth_img_bin; allow_scrolling_x = false; allow_scrolling_y = false; } else if (touch.py >= 2*48 && touch.py < 48*3) { picture = log_img_bin; subpicture = sublog_img_bin; allow_scrolling_x = false; allow_scrolling_y = true; } else if (touch.py >= 3*48 && touch.py < 48*4) { picture = debug_img_bin; subpicture = subdebug_img_bin; allow_scrolling_x = false; allow_scrolling_y = false; } } else if (touch.px > 256 - 48) { if (touch.py < 48) { picture = items_img_bin; subpicture = subitems_img_bin; allow_scrolling_x = false; allow_scrolling_y = false; } else if (touch.py >= 48 && touch.py < 48*2) { picture = scan_img_bin; subpicture = subscan_img_bin; allow_scrolling_x = true; allow_scrolling_y = true; } else if (touch.py >= 2*48 && touch.py < 48*3) { picture = comm_img_bin; subpicture = subcomm_img_bin; allow_scrolling_x = false; allow_scrolling_y = false; } else if (touch.py >= 3*48 && touch.py < 48*4) { picture = weapon_img_bin; subpicture = subweapon_img_bin; allow_scrolling_x = false; allow_scrolling_y = false; } } if (picture) { for(int i = 0; i < 256*192/2; ++i) ((u16*)BG_BMP_RAM_SUB(4))[i] = ((u16*)picture)[i]; TransferSoundData blaster = { blaster_bin, /* Sample address */ blaster_bin_size, /* Sample length */ 11025, /* Sample rate */ 127, /* Volume */ 64, /* panning */ 1 /* format */ }; playSound(&blaster); if (subpicture) { for(int i = 0; i < 256*256/2; ++i) ((u16*)BG_BMP_RAM_SUB(0))[i] = ((u16*)subpicture)[i]; } } else { // Didn't click on anything, so we assume middle region touch_down = touch; oldx = x; oldy = y; drag = true; } } }
void Render::DisplayHelpScreen() { dmaCopyHalfWords(DMA_CHANNEL, helpscreenBitmap, (uint16 *)BG_BMP_RAM_SUB(9), helpscreenBitmapLen); }
/* * DS display support. * Based off Dovoto's tutorials. * 2010 (C) The Lemon Man */ #include <types.h> #include "screen.h" static uint16_t *video_main = (uint16_t *)BG_BMP_RAM(0); static uint16_t *video_sub = (uint16_t *)BG_BMP_RAM_SUB(0); void screen_init(void) { DISPSTAT = (1 << 3); /* Initialize the screens */ POWCNT1 = 0x820E; /* Setup the screens */ DISPLAY_CR = 0x10005 | (1 << 11); SUB_DISPLAY_CR = 0x10005 | (1 << 11); /* Setup the vram banks */ VRAM_A_CR = 0x80 | 1; VRAM_C_CR = 0x80 | 4; /* Setup the backgrounds */ background_main.control[3] = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_ON; background_sub.control[3] = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_ON; /* Setup the matrices for both screens */ background_main.bg3_rotation.xdy = 0; background_main.bg3_rotation.xdx = 1 << 8; background_main.bg3_rotation.ydx = 0; background_main.bg3_rotation.ydy = 1 << 8;