コード例 #1
0
void CGbaLoader::LoadBorder(void)
{
  videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);

  // for the main screen
  REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_OFF;
  REG_BG3PA = 1 << 8; //scale x
  REG_BG3PB = 0; //rotation x
  REG_BG3PC = 0; //rotation y
  REG_BG3PD = 1 << 8; //scale y
  REG_BG3X = 0; //translation x
  REG_BG3Y = 0; //translation y

  memset((void*)BG_BMP_RAM(0),0,0x18000);
  memset((void*)BG_BMP_RAM(8),0,0x18000);

  cBMP15 frameBMP=createBMP15FromFile(SFN_GBAFRAME);
  if(frameBMP.valid()&&frameBMP.width()==SCREEN_WIDTH&&frameBMP.height()==SCREEN_HEIGHT)
  {
    DC_FlushRange(frameBMP.buffer(),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    dmaCopy(frameBMP.buffer(),(void*)BG_BMP_RAM(0),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    dmaCopy(frameBMP.buffer(),(void*)BG_BMP_RAM(8),SCREEN_WIDTH*SCREEN_HEIGHT*2);
  }
}
コード例 #2
0
ファイル: boot9.cpp プロジェクト: suloku/fas1
void gbaFrame(void)
{
  u16* frame=NULL;
  cBMP15 frameBMP=createBMP15FromFile("/GBA/gbaframe.bmp");
  if(frameBMP.valid()&&frameBMP.width()==SCREEN_WIDTH&&frameBMP.height()==SCREEN_HEIGHT)
  {
    frame=(u16*)malloc(SCREEN_WIDTH*SCREEN_HEIGHT*2);
    memcpy(frame,frameBMP.buffer(),SCREEN_WIDTH*SCREEN_HEIGHT*2); //tricky thing
  }

  videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);

  // for the main screen
  BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_OFF;
  BG3_XDX = 1 << 8; //scale x
  BG3_XDY = 0; //rotation x
  BG3_YDX = 0; //rotation y
  BG3_YDY = 1 << 8; //scale y
  BG3_CX = 0; //translation x
  BG3_CY = 0; //translation y

  if(frame)
  {
    dmaCopy(frame,(void*)BG_BMP_RAM(0),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    dmaCopy(frame,(void*)BG_BMP_RAM(8),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    free(frame);
  }
  else
  {
    memset((void*)BG_BMP_RAM(0),0,0x18000);
    memset((void*)BG_BMP_RAM(8),0,0x18000);
  }
}
コード例 #3
0
Graphics::Graphics(void) {
	//irqInit(); 
	//irqSet(IRQ_VBLANK, 0); 
	setColor(RGB15(20,31,10) | (1<<15));
			 
	videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
	//videoSetModeSub(MODE_2_2D | DISPLAY_BG3_ACTIVE);
			
	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankB(VRAM_B_MAIN_BG);
	//vramSetBankC(VRAM_C_SUB_BG);
			
			
	REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0);
	REG_BG3PA  = 1 << 8;
	REG_BG3PB  = 0;
	REG_BG3PC  = 0;
	REG_BG3PD  = 1 << 8;
	videoRam   = BG_BMP_RAM(0);
			
			
	//REG_BG3CNT_SUB = BG_BMP16_256x256 | BG_BMP_BASE(0);
	//REG_BG3PA_SUB = 1<< 8;
	//REG_BG3PB_SUB = 0;
	//REG_BG3PC_SUB = 0;
	//REG_BG3PD_SUB = 1 << 8;
	//memClone   = BG_BMP_RAM_SUB(2);
}
コード例 #4
0
ファイル: render.cpp プロジェクト: jsykes/starkas
void Render::DisplayTeamLogo() {
    dmaCopyHalfWords(DMA_CHANNEL,
                   teamLogoBitmap, /* This variable is generated for us by
                                       * grit. */
                     (uint16 *)BG_BMP_RAM(0), /* Our address for 
                                               * background 3 */
                     teamLogoBitmapLen);
}
コード例 #5
0
ファイル: main.cpp プロジェクト: Patater/manual
void displayPlanet() {
    dmaCopyHalfWords(DMA_CHANNEL,
                     planetBitmap, /* This variable is generated for us by
                                    * grit. */
                     (uint16 *)BG_BMP_RAM(8), /* Our address for main
                                               * background 2 */
                     planetBitmapLen); /* This length (in bytes) is generated
                                        * from grit. */
}
コード例 #6
0
ファイル: main.cpp プロジェクト: Patater/manual
void displayStarField() {
    dmaCopyHalfWords(DMA_CHANNEL,
                     starFieldBitmap, /* This variable is generated for us by
                                       * grit. */
                     (uint16 *)BG_BMP_RAM(0), /* Our address for main
                                               * background 3 */
                     starFieldBitmapLen); /* This length (in bytes) is
                                           * generated from grit. */
}
コード例 #7
0
ファイル: subpix.c プロジェクト: NickMcConnell/OangbandU
void draw_char_subpix(byte x, byte y, char c) {
  u32b vram_offset = y * 8 * 256 + x * 3, tile_offset = c * 24;
  u16b* fb = (u16b*) BG_BMP_RAM(ANG_BMP_BASE_MAIN_OVER);
  const u16b* chardata = top_font_bin;
  byte xx, yy;
  if (x > 84) return;
  for (yy = 0; yy < 8; yy++)
    for (xx = 0; xx < 3; xx++) 
      fb[yy * 256 + xx + vram_offset] 
	= chardata[yy * 3 + xx + tile_offset] | BIT(15);
}
コード例 #8
0
ファイル: hardware.cpp プロジェクト: ant512/EarthShakerDS
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();
}
コード例 #9
0
ファイル: subpix.c プロジェクト: NickMcConnell/OangbandU
void draw_color_char_subpix(byte x, byte y, char c, byte clr) {
  u32b vram_offset = (y & 0x1F) * 8 * 256 + x * 3, tile_offset = c * 24;
  u16b* fb = (u16b*) BG_BMP_RAM(ANG_BMP_BASE_MAIN_OVER);
  const u16b* chardata = top_font_bin;
  byte xx, yy;
  u16b val;
  u16b fgc = color_data[clr & 0xF];
  if (x > 84) return;
  for (yy = 0; yy < 8; yy++) {
    for (xx = 0;xx < 3; xx++) {
      val = (chardata[yy * 3 + xx + tile_offset]);
      fb[yy * 256 + xx + vram_offset] = (val  & fgc) | BIT(15);
    }
  }
}
コード例 #10
0
ファイル: OSGLUNDS.c プロジェクト: libretro/libretro-minivmac
LOCALPROC HaveChangedScreenBuff(ui4r top, ui4r left,
	ui4r bottom, ui4r right)
{
	/*
		Oh god, clean this up.
	*/
	u8 *octpix = NULL;
	u32 *vram = NULL;

	octpix = (u8 *)GetCurDrawBuff();
	vram = (u32 *)BG_BMP_RAM(0);

	octpix += ((top * vMacScreenWidth ) >> 3);
	vram += ((top * vMacScreenWidth ) >> 2);

	FB1BPPtoIndexed(vram, octpix,
		((bottom - top) * vMacScreenWidth) >> 3);
}
コード例 #11
0
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];
}
コード例 #12
0
ファイル: nds_cmd.c プロジェクト: robbsherwin/nethackds
#ifdef WIZARD
    {C('e'), "Wiz-Detect"},
    {C('g'), "Wiz-Genesis"},
    {C('i'), "Wiz-Identify"},
    {C('f'), "Wiz-Map"},
    {C('v'), "Wiz-Tele"},
    {C('o'), "Wiz-Where"},
    {C('w'), "Wiz-Wish"},
#endif
    {0, NULL}
};

rectangle_t up_arrow_rect;
rectangle_t down_arrow_rect;

u16 *vram = (u16 *)BG_BMP_RAM(12);

nds_cmd_t ***cmd_matrix;
u16 **cmd_pages;
int cmd_page_count;
int cmd_page_size;

int cmd_col_width = 0;
int cmd_page_rows = 0;
int cmd_page_cols = 0;

int cmd_rows = 0;
int cmd_cols = 0;

int cmd_cur_page = 0;
コード例 #13
0
ファイル: arm9_main.c プロジェクト: 0xtob/dsmi
#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);
	  bg3vram[ i + 256 * old_kaos_y] = RGB15(0,0,0);
コード例 #14
0
ファイル: screen.c プロジェクト: LemonBoy/PrexDS
/*
 * 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;
コード例 #15
0
ファイル: render.cpp プロジェクト: jsykes/starkas
void Render::DisplayLevelSeven()
{
	dmaCopyHalfWords(DMA_CHANNEL, level7Bitmap, (uint16 *)BG_BMP_RAM(0), level7BitmapLen);
}
コード例 #16
0
ファイル: nds_win.c プロジェクト: paulog/nethackds
void _nds_draw_scroller(nds_nhwindow_t *window, int clear)
{
  u16 *vram = (u16 *)BG_BMP_RAM(2);

  int start_x, end_x, start_y, end_y;

  int maxidx;

  start_x = (256 / 2 - (window->region.dims.width / 2));
  end_x = 256 / 2 + (window->region.dims.width / 2);

  if (window->buffer == NULL) {
    start_x -= tag_width;
    end_x += tag_width;
  }

  if (start_x < 0) {
    end_x -= start_x;
    start_x = 0;
  }

  if (window->region.dims.height > 192 - 32) {
    start_y = 16;
    end_y = 192 - 16;
  } else {
    start_y = 192 / 2 - window->region.dims.height / 2;
    end_y = 192 / 2 + window->region.dims.height / 2;
  }

  swiWaitForVBlank();

  if (window->buffer == NULL) {
    nds_menu_t *menu = window->menu;
    int cur_y = 0;
    int i;

    if (clear) {
      nds_fill(vram, MAP_COLOUR(CLR_BLACK));
    }

    if (! window->img) {
      window->img = alloc_ppm(end_x - start_x, system_font->height * TITLE_MAX_LINES);
    }

    for (i = window->topidx; (i < menu->count) && ((cur_y + menu->items[i].region.dims.height) <= (end_y - start_y)); i++) {
      if (clear || menu->items[i].refresh) {
        char tag[3] = "  ";
        int linenum = 0;
        int fg, bg;

        fg = (menu->items[i].highlighted) ? CLR_BRIGHT_GREEN : -1;
        bg = (menu->focused_item == i) ? CLR_BLUE : -1;

        window->img->height = menu->items[i].region.dims.height;

        clear_ppm(window->img, MAP_COLOUR(bg));

        if (menu->items[i].selected) {
          if (menu->items[i].count > 0) {
            sprintf(tag, "%d", menu->items[i].count);
          } else {
            strcpy(tag, "* ");
          }
        }

        for (linenum = 0; menu->items[i].title[linenum][0]; linenum++) {
          int yoffs = linenum * system_font->height;

          if (menu->items[i].id.a_int == 0) {
            draw_string(system_font,
                        menu->items[i].title[linenum],
                        window->img, 0, yoffs, 
                        fg, bg);
          } else {
            if (linenum == 0) {
              draw_string(system_font,
                          tag,
                          window->img, 0, yoffs, 
                          fg, bg);
            }

            draw_string(system_font,
                        menu->items[i].title[linenum],
                        window->img, tag_width, yoffs, 
                        fg, bg);
          }
        }

        /* 
         * Yes, this is a complete frickin' hack.  Not all items take the full
         * image height, but rather than write a new version of draw_ppm_bw that
         * allowed cropping, I just change the height of the image to match the
         * height of the item.  This effectively crops the images to the height
         * of the item, while letting us use the same ppm struct during the
         * entire rendering process, which means fewer malloc/free pairs.
         */
        draw_ppm(window->img, vram, start_x, start_y + cur_y, 256);

        menu->items[i].refresh = 0;
      }

      menu->items[i].region.start.x = start_x + tag_width;
      menu->items[i].region.start.y = start_y + cur_y;

      cur_y += menu->items[i].region.dims.height;
    } 

    window->bottomidx = i - 1;
    maxidx = menu->count - 1;

    if (menu->how == PICK_ANY) {
      draw_ppm(okay_button, vram,
               256 - okay_button->width * 2 - 8, 192 - okay_button->height,
               256);
    }
  } else {
    nds_charbuf_t *charbuf = window->buffer;
    int cur_y = 0;
    int i;

    if (! window->img) {
      window->img = alloc_ppm(end_x - start_x, end_y - start_y);
    }
    
    clear_ppm(window->img, MAP_COLOUR(CLR_BLACK));

    for (i = window->topidx; (i < charbuf->count) && (cur_y < (end_y - start_y)); i++) {
      draw_string(system_font,
                  charbuf->lines[i].text,
                  window->img, 0, cur_y,
                  -1, -1);

      cur_y += charbuf->lines[i].height;
    }

    window->bottomidx = i - 1;
    maxidx = charbuf->count - 1;

    if (clear) {
      nds_fill(vram, 254);
    }

    draw_ppm(window->img, vram, start_x, start_y, 
             256);
  }

  if (window->topidx > 0) {
    draw_ppm(up_arrow, vram, 
             256 / 2 - up_arrow->width / 2, 0, 
             256);
  }

  if (window->bottomidx < maxidx) {
    draw_ppm(down_arrow, vram, 
             256 / 2 - down_arrow->width / 2, 192 - down_arrow->height, 
             256);
  }

  draw_ppm(cancel_button, vram,
           256 - cancel_button->width, 192 - cancel_button->height,
           256);
}
コード例 #17
0
ファイル: render.cpp プロジェクト: jsykes/starkas
void Render::DisplayStory7()
{
	dmaCopyHalfWords(DMA_CHANNEL, story7Bitmap, (uint16 *)BG_BMP_RAM(0), story7BitmapLen);
}
コード例 #18
0
ファイル: subpix.c プロジェクト: NickMcConnell/OangbandU
#include <main-nds.h>
#include "nds/ds_errfont.h" /* contains the subpixel font data in bgr */

extern u16b color_data[];

u16* subfont_rgb_bin = (u16*)BG_BMP_RAM(ANG_SUBPIX_BASE);// (0x06018400);
u16* subfont_bgr_bin = (u16*)BG_BMP_RAM(ANG_SUBPIX_BASE+1);// (0x0601C400);
u16* top_font_bin;
u16* btm_font_bin;

void nds_init_font_subpix() {
  // the font is now compiled in as ds_subfont for error reporting purposes
  // ds_subfont contains the bgr version
  //subfont_bgr_bin = &ds_subfont[0];
  u16b i,t,t2;
  for (i=0;i<8*3*256;i++) {
    t = ds_subfont[i];
    t2 = t & 0x8000;
    t2 |= (t & 0x001f)<<10;
    t2 |= (t & 0x03e0);
    t2 |= (t & 0x7c00)>>10;
    subfont_bgr_bin[i] = t;
    subfont_rgb_bin[i] = t2;
  }
  top_font_bin = subfont_bgr_bin;
  btm_font_bin = subfont_rgb_bin;
}

void swap_font(bool bottom) {
  if (!bottom) {