Exemplo n.º 1
0
void init(){
	// Set display options.
	REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_BG3;
	
	// Set background 0 options.
	REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32;
	REG_BG0HOFS = 0;
	REG_BG0VOFS = 0;
	// Set background 1 options.
	REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32;
	REG_BG1HOFS = 0;
	REG_BG1VOFS = 0;
	// Set background 2 options.
	REG_BG2CNT = BG_CBB(0) | BG_SBB(28) | BG_8BPP | BG_REG_32x32;
	REG_BG2HOFS = 0;
	REG_BG2VOFS = 0;
	// Set background 3 options.
	REG_BG3CNT = BG_CBB(0) | BG_SBB(27) | BG_8BPP | BG_REG_32x32;
	REG_BG3HOFS = 0;
	REG_BG3VOFS = 0;
	
	LoadTileData(0, 0, backgroundTiles, backgroundTilesLen);
	LoadPaletteBGData(0, menuBGPal, menuBGPalLen);
	
	LoadTileData(4, 0, spritesTiles, spritesTilesLen);
	LoadTileData(4, 64, font_bold, 8192);
	LoadPaletteObjData(0, spritesPal, spritesPalLen);
	
	//Clear backgrounds
	for (int y = 0; y < 32; ++y){
	for (int x = 0; x < 32; ++x){
		SetTile(30, x, y, 0);
		SetTile(29, x, y, 0);
		SetTile(28, x, y, 0);
		SetTile(27, x, y, 0);
	}
	}
	
	//Set-up backgrounds from maps
	for(int i = 0; i < cloudBGMapLen; i++){
		SetTile(27, i%32, i/32, cloudBGMap[i]);
	};
	for(int i = 0; i < buildingBGMapLen; i++){
		SetTile(28, i%32, i/32, buildingBGMap[i]);
	};
	for(int i = 0; i < fenceBGMapLen; i++){
		SetTile(29, i%32, i/32, fenceBGMap[i]);
	};
	for(int i = 0; i < girderMapLen; i++){
		SetTile(30, i%32, i/32, girderMap[i]);
	};
}
Exemplo n.º 2
0
void InitialiseStage()
{
    REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ | DCNT_OBJ_1D | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_BG3;


    REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32;
    REG_BG1CNT = BG_CBB(1) | BG_SBB(29) | BG_8BPP | BG_REG_32x32;
    REG_BG2CNT = BG_CBB(1) | BG_SBB(28) | BG_8BPP | BG_REG_32x32;
    REG_BG3CNT = BG_CBB(1) | BG_SBB(27) | BG_8BPP | BG_REG_32x32;

    DrawChessBoard();
    PlacePieces();
}
Exemplo n.º 3
0
//! Testing rendering speeds.
void test_speeds()
{
	irq_init(NULL);
	irq_add(II_VBLANK, NULL);

	gFont= vwf_default;

	int ii;
	const char *str= glados[0];
	int len= strlen(str);

	for(ii=0; ii<countof(gProfs); ii++)
	{
		gProfs[ii].proc(&gProfs[ii], str);
		key_wait_till_hit(KEY_ANY);
	}

	RegisterRamReset(RESET_GFX);
	REG_DISPCNT= DCNT_MODE0 | DCNT_BG2;

	tte_init_se_default(2, BG_CBB(0) | BG_SBB(24));
	tte_init_con();
	pal_bg_bank[14][1]= CLR_ORANGE;

	iprintf("%d\n", len);
	for(ii=0; ii<countof(gProfs); ii++)
	{
		tte_set_special(SE_PALBANK(14+(ii&1)));
		iprintf("%-17s %6d  %d\n", gProfs[ii].str, gProfs[ii].time, 
			gProfs[ii].time/len);
	}

	key_wait_till_hit(KEY_START);
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: Alanh168/test
int main()
{
	// Init interrupts and VBlank irq.
	irq_init(NULL);
	irq_add(II_VBLANK, NULL);
	
	// Video mode 0, enable bg 0.
	REG_DISPCNT= DCNT_MODE0 | DCNT_BG0;
	
	// Init 4bpp vwf text on bg 0.
	tte_init_chr4c(0, 			// BG 0
		BG_CBB(0)|BG_SBB(31),	// Charblock 0; screenblock 31
		0xF000,					// Screen-entry offset
		bytes2word(1,2,0,0),	// Color attributes.
		CLR_YELLOW, 			// Yellow text
		&verdana9Font,			// Verdana 9 font
		NULL					// Use default chr4 renderer
		);
	
	// Initialize use of stdio.
	tte_init_con();
	
	// Printf something at 96,72
	tte_printf("#{P:96,72}Hello World!");
	
	while(1)
	{
		VBlankIntrWait();
	}
	
	return 0;
}
Exemplo n.º 5
0
void prof_chr4c_base(TProfiler *prof, const char *str, fnDrawg proc)
{
	RegisterRamReset(RESET_GFX);
	REG_DISPCNT= DCNT_MODE0 | DCNT_BG2;
	
	tte_init_chr4c(2, BG_CBB(0)|BG_SBB(24), 0xF000, 0x0201, CLR_YELLOW,
		&gFont, proc);

	prof_draws(prof, str);
}
Exemplo n.º 6
0
void init_game()
{
   //Initialization
   
   //Field_0
   memcpy(pal_bg_mem, bd_forestPal, bd_forestPalLen);
   memcpy(&tile_mem[0][0], bd_forestTiles, bd_forestTilesLen);
   memcpy(&se_mem[30][0], bd_forestMap, bd_forestMapLen);
   
   REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_4BPP | BG_REG_32x32 | BG_PRIO(1);
   
   //Bg_Forest
   memcpy(&pal_bg_bank[1], bg_forestPal, bg_forestPalLen);
   memcpy(&tile_mem[0][16], bg_forestTiles, bg_forestTilesLen);
   memcpy(&se_mem[28][0], bg_forestMap, bg_forestMapLen);
   
   REG_BG1CNT = BG_CBB(0) | BG_SBB(28) | BG_4BPP | BG_REG_64x32 | BG_PRIO(0);
   
   
   memcpy(&tile8_mem[4][0], pikmin_sheetTiles, pikmin_sheetTilesLen);
   memcpy(pal_obj_mem, pikmin_sheetPal, pikmin_sheetPalLen);
	
	
	REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_OBJ| DCNT_OBJ_1D;
	
	oam_init(obj_buffer, 128);
	
	u32 tid=0, pb=0;
	
	OBJ_ATTR *pkm = &obj_buffer[0];
	
	obj_set_attr(pkm, 
	             ATTR0_TALL, 
	             ATTR1_SIZE_16x32, 
	             ATTR2_PALBANK(pb) | tid);
	             
	pkm->attr0 |= ATTR0_8BPP;
	
	oam_copy(oam_mem, obj_buffer, 1);
}
Exemplo n.º 7
0
void prof_ase_drawg(TProfiler *prof, const char *str)
{
	RegisterRamReset(RESET_GFX);
	REG_DISPCNT= DCNT_MODE1 | DCNT_BG2;

	int charH= gFont.charH;			gFont.charH= 16;
	const u8 *widths= gFont.widths;	gFont.widths= NULL;
	
	tte_init_ase(2, BG_CBB(0)|BG_SBB(24) | BG_AFF_32x32, 0, CLR_YELLOW, 0, 
		&gFont, ase_drawg);

	prof_draws(prof, str);

	gFont.charH= charH;
	gFont.widths= widths;	
}
Exemplo n.º 8
0
void CreditDevkitArmandtonc()
{
	RegisterRamReset(RESET_GFX);

	REG_DISPCNT= DCNT_MODE0 | DCNT_BG0;

	tte_init_chr4c(0, 			// BG 0
		BG_CBB(0)|BG_SBB(31),	// Charblock 0; screenblock 31
		0xF000,					// Screen-entry offset
		bytes2word(1,2,0,0),	// Color attributes.
		CLR_WHITE, 			// White text
		&verdana9Font,			// Verdana 9 font
		NULL
		);

	vid_vsync();
	tte_write("#{P:35,60}Credit to Wintermute for devkitARM!\n");
	tte_write("#{P:35,70}Credit to Cern for Tonc!");

	waitsecs(7);
}
Exemplo n.º 9
0
int main()
{
	// Set display options.
	// DCNT_MODE0 sets mode 0, which provides four tiled backgrounds.
	// DCNT_OBJ enables objects.
	// DCNT_OBJ_1D make object tiles mapped in 1D (which makes life easier).
	REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_OBJ;
	
	REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32 | BG_PRIO(0);
	
	REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32 | BG_PRIO(1);
	
	REG_BG2CNT = BG_CBB(0) | BG_SBB(25) | BG_8BPP | BG_REG_64x64 | BG_PRIO(2);
	REG_BG2HOFS = 0;
	REG_BG2VOFS = 0;
	
	ClearObjects();
	
	SetPaletteBG(1, RGB(31, 31, 31)); // white
	
	//Load each tile in font_bold into it's corresponding position in charblock 0
	for (int i = 0; i < 128; i++)
	{
		LoadTile8(0, i, font_bold[i]);
	}
	
	DrawText(5, (SCREEN_HEIGHT / 16) - 2, "DECEPTIVE DIMENSIONS");
	DrawText(5, (SCREEN_HEIGHT / 16), "Press start to begin");
	
	Buttons buttons;
	int framecounter = 0;
	
	//Title screen (under construction)
	while (true)
	{
		buttons.Update();
		
		if (buttons.StartJustPressed())
		{
			break;
		}
		
		WaitVSync();	
	}
	
	while (true)
	{
		//Load Custom spritesheet
		LoadPaletteObjData(0, spritesheet4Pal, sizeof spritesheet4Pal);
		LoadPaletteBGData(0, backgroundnewnewPal, sizeof backgroundnewnewPal);
		LoadTileData(4, 0, spritesheet4Tiles, sizeof spritesheet4Tiles);
		LoadTileData(0, 0, backgroundnewnewTiles, sizeof backgroundnewnewTiles);
		
		int levelnumber = 1;
		
		Level level(levelnumber);
		
		for (int screenblock = 21; screenblock < 31; screenblock++)
		{
			level.FillScreenblock(screenblock, 0);
		}
		
		level.DrawBackground(level.curdimension);
		
		bool gamerunning = true;
		
		//Main game loop
		while (gamerunning)
		{
			buttons.Update();
			
			gamerunning = level.CheckIfLevelComplete();
			level.TakeInput(buttons);
			level.MoveObjects();
			level.Draw();
			level.UpdateLevelObjects(framecounter);

			framecounter++;
			
			WaitVSync();
			FlipBuffers();
		}
		
		//Reload each tile in font_bold into it's corresponding position in charblock 0
		for (int i = 0; i < 128; i++)
		{
			LoadTile8(0, i, font_bold[i]);
		}
		
		SetPaletteBG(0, RGB(0, 0, 0)); // black
		SetPaletteBG(1, RGB(31, 31, 31)); // white		
		
		for (int screenblock = 25; screenblock < 31; screenblock++)
		{
			for (int y = 0; y < 32; y++)
			{
				for (int x = 0; x < 32; x++)
				{
					SetTile(screenblock, x, y, 0);
				}
			}
		}
		
		level.player.drawx = SCREEN_WIDTH;
		
		SetObject(level.player.GetObjNum(),
		  ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_HIDE,
		  ATTR1_SIZE(2) | ATTR1_X(level.player.drawx),
		  ATTR2_ID8(0) | ATTR2_PRIO(2));
		
		UpdateObjects();
		
		DrawText(6, (SCREEN_HEIGHT / 16) - 2, "That's all folks!!");
		DrawText(3, (SCREEN_HEIGHT / 16), "Press start to try again");
		
		while (true)
		{
			buttons.Update();
			
			if (buttons.StartJustPressed())
			{
				break;
			}
			
			WaitVSync();
		}
	}
}
Exemplo n.º 10
0
void scene_BuildBattleScreen()
{
	REG_BG0CNT = BG_4BPP | BG_SIZE2 | BG_PRIO(0) | 24 << BG_SBB_SHIFT | 0 << BG_CBB_SHIFT;
	REG_BG3CNT = BG_4BPP | BG_SIZE1 | BG_PRIO(3) | 26 << BG_SBB_SHIFT | 2 << BG_CBB_SHIFT;
	REG_BLDCNT = 0;
	DmaClear(0, MEM_VRAM, 0xFFFF);
	//DmaClear(0, MEM_VRAM, 0xF000);

	ClearOamBak();

	REG_DISPCNT |=  DCNT_WIN0;
	REG_WIN0H = 240;
	REG_WIN0V = 112;
	REG_WININ = WIN_BG3 | WIN_BG2 | WIN_BG1 | WIN_BG0 | WIN_OBJ | WIN_BLD;
	REG_WINOUT = 0;

	vwf_init(0, BG_CBB(0) | BG_SBB(24), fontWesternTiles, fontWesternWidths);
	vwDestination = (u32*)VWDEST_BATTLE;
	vwClear(1);

	CpuFastArrayCopy(battleinterfaceTiles,MEM_VRAM);
	CpuFastCopy(battleinterfacePal, MEM_PAL_BG + 0x1C0, 16);
	CpuFastCopy(framePal, MEM_PAL_BG + 0x1E0, 16);
	CpuFastCopy(frameTiles + (0x90 * MyPlayer.Options.frame),MEM_VRAM+0x240,0x120);

	u16* meh = (u16*)(MEM_VRAM + 0xC000);
	int i;
	for(i=0; i < 640*3; i++)
		meh[i] = battleinterfaceMap[i] + 0xE000;
	//	meh[i] = grassMap[i] + 0x1000;

	//scene_DrawFrame(0,30,14,6);
	scene_SetLine(1,28,15,96,14);
	scene_SetLine(1,28,17,160,14);

	//scene_DrawFrame(0,15,34,6);
	scene_SetLine(1,13,35,224,14);
	scene_SetLine(1,13,37,288,14);
	//scene_DrawFrame(15,15,34,6);
	vwClearLine(1,9);
	vwClearLine(1,13);
	vwWriteG(16,4,strBattleFight);
	//vwf_set_color(TEXT_INK, 3);
	vwWriteG(24,4,strBattleBag);
	//vwNormalLUT();
	vwWriteG(16,6,strBattlePokemon);
	vwWriteG(24,6,strBattleRun);
	scene_SetLine(17,6,35,240,15);
	scene_SetLine(24,5,35,248,15);
	scene_SetLine(17,6,37,304,15);
	if(!ThisBattle.trainer) scene_SetLine(24,5,37,312,15);

	//scene_DrawFrame(0,20,54,6);
	scene_SetLine(2,8,55,352,15);
	scene_SetLine(11,8,55,416,15);
	scene_SetLine(2,8,57,480,15);
	scene_SetLine(11,8,57,544,15);
	//scene_DrawFrame(20,10,54,6);
	scene_SetLine(21,8,55,368,15);
	scene_SetLine(21,8,57,376,15);

	vwWriteG(31,4,strArrow);

	//ThisBattle.background
	AGBPrintf("Supposed to copy battle background from 0x%x.\n",battlebacks[ThisBattle.background*4]);
	DmaCopy(battlebacks[ThisBattle.background*4], MEM_VRAM + 0x8000, 0x1000);
	DmaCopy(battlebacks[(ThisBattle.background*4)+1], MEM_VRAM + 0xD000, 0x1000);
	if(currentLevel->tileseta->flags && 1)
		DmaCopy(battlebacks[(ThisBattle.background*4)+2], MEM_PAL_BG, 32);
	else
		LoadTimeAdjustedColors((u16*)MEM_PAL_BG, (u16*)battlebacks[(ThisBattle.background*4)+2], 16);
	ThisBattle.environment = battlebacks[(ThisBattle.background*4)+3];
	//DmaArrayCopy(battlegrassTiles, MEM_VRAM + 0x8000);
	//DmaArrayCopy(battlegrassMap, MEM_VRAM + 0xD000);
	//LoadTimeAdjustedColors((u16*)MEM_PAL_BG, (u16*)battlegrassPal, 16);

	REG_BG3HOFS = 0;
	REG_BG3VOFS = 0;

	OamBak[0].Shape = 0;
	OamBak[0].Size = 3;
	OamBak[1].Shape = 0;
	OamBak[1].Size = 3;

//	DmaArrayCopy(playerwindowPal, MEM_PAL_OBJ + 0x10a0);
//	DmaArrayCopy(hpbarPal, MEM_PAL_OBJ + 0x10c0);

	DmaArrayCopy(btlstatusTiles, MEM_VRAM_OBJ + 0x3580);
	DmaArrayCopy(btlstatusPal, MEM_PAL_OBJ + 0xE0);
}
Exemplo n.º 11
0
int playPuzzle(int NUR_ROWS, int NUR_COLS, int puzzle[NUR_ROWS][NUR_COLS], int puzzle_index) {

  int cursor_r = 0;
  int cursor_c = 0;

  // Load palette
  memcpy16(pal_bg_mem, SharedPal, SharedPalLen / 2);

  // Load tiles into CBB 0 (16x16) and 1 (8x8)
  // Each charblock is 0x4000, an 8x8 tile is 0x20 bytes,
  // so there are 512 8x8 tiles or 128 16x16 tiles in each charblock.
  memcpy16(tile_mem[0], tiles16Tiles, tiles16TilesLen / 2);
  memcpy16(tile_mem[1], tiles8Tiles, tiles8TilesLen / 2);

  // Load the 16x16 puzzle map into screenblocks 28-31
  for (int r = 0; r < 32; r++) {
    for (int c = 0; c < 32; c++) {
      set_tile(28, r, c, OUTSIDE);
    }
  }
  for (int c = 0; c < NUR_COLS; c++) set_tile(28, NUR_ROWS, c, BOTTOM_EDGE);
  for (int r = 0; r < NUR_ROWS; r++) set_tile(28, r, NUR_COLS, RIGHT_EDGE);
  set_tile(28, NUR_ROWS, NUR_COLS, BOTTOM_RIGHT_CORNER);
  for (int r = 0; r < NUR_ROWS; r++) {
    for (int c = 0; c < NUR_COLS; c++) {
      set_tile(28, r, c, puzzle[r][c]);
    }
  }

  // Load the 16x16 cursor map into screenblocks 24-27
  for (int r = 0; r < 32; r++) {
    for (int c = 0; c < 32; c++) {
      set_tile(24, r, c, TRANSPARENT);
    }
  }
  set_tile(24, cursor_r, cursor_c, CURSOR);

  // 8x8 tiles:
  // set up BG2 for a 4bpp 32x32t map, using charblock 1 and screenblock 22 (cursor)
  REG_BG2CNT = BG_CBB(1) | BG_SBB(22) | BG_4BPP | BG_REG_32x32;
  // set up BG3 for a 4bpp 32x32t map, using charblock 1 and screenblock 23 (puzzle squares)
  REG_BG3CNT = BG_CBB(1) | BG_SBB(23) | BG_4BPP | BG_REG_32x32;
  // 16x16 tiles:
  // set up BG0 for a 4bpp 64x64t map, using charblock 0 and screenblocks 24-27 (cursor)
  REG_BG0CNT = BG_CBB(0) | BG_SBB(24) | BG_4BPP | BG_REG_64x64;
  // set up BG1 for a 4bpp 64x64t map, using charblock 0 and screenblocks 28-31 (puzzle squares)
  REG_BG1CNT = BG_CBB(0) | BG_SBB(28) | BG_4BPP | BG_REG_64x64;
  if (small_tiles) {
    REG_DISPCNT = DCNT_MODE0 | DCNT_BG2 | DCNT_BG3;
  }
  else {
    REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1;
  }

  int max_horiz_offset_16 = NUR_COLS * 16 - 240;
  if (max_horiz_offset_16 < 0) max_horiz_offset_16 = 0;
  int max_vert_offset_16  = NUR_ROWS * 16 - 160;
  if (max_vert_offset_16 < 0) max_vert_offset_16 = 0;

  int max_horiz_offset_8 = NUR_COLS * 8 - 240;
  if (max_horiz_offset_8 < 0) max_horiz_offset_8 = 0;
  int max_vert_offset_8  = NUR_ROWS * 8 - 160;
  if (max_vert_offset_8 < 0) max_vert_offset_8 = 0;

  REG_BG0HOFS = REG_BG1HOFS = REG_BG2HOFS = REG_BG3HOFS = 0;
  REG_BG0VOFS = REG_BG1VOFS = REG_BG2VOFS = REG_BG3VOFS = 0;

  irq_init(NULL);
  irq_add(II_VBLANK, NULL);

  int key_repeat = 0;
  bool clearing = false;
  while (1) {
    VBlankIntrWait();
    key_poll();
    set_tile(24, cursor_r, cursor_c, TRANSPARENT); // remove the cursor
    if (key_hit(1 << KI_LEFT | 1 << KI_RIGHT | 1 << KI_UP | 1 << KI_DOWN)) {
      key_repeat = 0; // reset the key repeat timer
    }
#define START_REPEAT 20
#define REPEAT_SPEED 2
    if (key_is_down(1 << KI_LEFT | 1 << KI_RIGHT | 1 << KI_UP | 1 << KI_DOWN)) {
      if (key_repeat < START_REPEAT) key_repeat++;
      else key_repeat = START_REPEAT - REPEAT_SPEED;
    }
    bool virtual_left  = key_hit(1 << KI_LEFT ) || (key_is_down(1 << KI_LEFT ) && key_repeat == START_REPEAT);
    bool virtual_right = key_hit(1 << KI_RIGHT) || (key_is_down(1 << KI_RIGHT) && key_repeat == START_REPEAT);
    bool virtual_up    = key_hit(1 << KI_UP   ) || (key_is_down(1 << KI_UP   ) && key_repeat == START_REPEAT);
    bool virtual_down  = key_hit(1 << KI_DOWN ) || (key_is_down(1 << KI_DOWN ) && key_repeat == START_REPEAT);
    bool moved_cursor = false;
    if (virtual_left  && cursor_c > 0           ) {
      cursor_c--;
      REG_BG0HOFS = REG_BG1HOFS = (cursor_c * max_horiz_offset_16) / (NUR_COLS - 1);
      REG_BG2HOFS = REG_BG3HOFS = (cursor_c * max_horiz_offset_8 ) / (NUR_COLS - 1);
      moved_cursor = true;
    }
    if (virtual_right && cursor_c < NUR_COLS - 1) {
      cursor_c++;
      REG_BG0HOFS = REG_BG1HOFS = (cursor_c * max_horiz_offset_16) / (NUR_COLS - 1);
      REG_BG2HOFS = REG_BG3HOFS = (cursor_c * max_horiz_offset_8 ) / (NUR_COLS - 1);
      moved_cursor = true;
    }
    if (virtual_up    && cursor_r > 0           ) {
      cursor_r--;
      REG_BG0VOFS = REG_BG1VOFS = (cursor_r * max_vert_offset_16) / (NUR_ROWS - 1);
      REG_BG2VOFS = REG_BG3VOFS = (cursor_r * max_vert_offset_8 ) / (NUR_ROWS - 1);
      moved_cursor = true;
    }
    if (virtual_down  && cursor_r < NUR_ROWS - 1) {
      cursor_r++;
      REG_BG0VOFS = REG_BG1VOFS = (cursor_r * max_vert_offset_16) / (NUR_ROWS - 1);
      REG_BG2VOFS = REG_BG3VOFS = (cursor_r * max_vert_offset_8 ) / (NUR_ROWS - 1);
      moved_cursor = true;
    }

    if (key_hit(1 << KI_A)) {
      switch (puzzle[cursor_r][cursor_c]) {
        case WHITE:
        case BLACK:
          puzzle[cursor_r][cursor_c] = DOT;
          sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = DOT;
          set_tile(28, cursor_r, cursor_c, DOT);
          clearing = false;
          break;
        case DOT:
          puzzle[cursor_r][cursor_c] = WHITE;
          sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = WHITE;
          set_tile(28, cursor_r, cursor_c, WHITE);
          clearing = true;
          break;
        default:
          clearing = false;
          break;
      }
    }
    else if (key_is_down(1 << KI_A) && moved_cursor) {
      switch (puzzle[cursor_r][cursor_c]) {
        case WHITE:
        case BLACK:
        case DOT:
          if (clearing) {
            puzzle[cursor_r][cursor_c] = WHITE;
            sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = WHITE;
            set_tile(28, cursor_r, cursor_c, WHITE);
          }
          else {
            puzzle[cursor_r][cursor_c] = DOT;
            sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = DOT;
            set_tile(28, cursor_r, cursor_c, DOT);
          }
          break;
      }
    }

    if (key_hit(1 << KI_B)) {
      switch (puzzle[cursor_r][cursor_c]) {
        case WHITE:
        case DOT:
          puzzle[cursor_r][cursor_c] = BLACK;
          sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = BLACK;
          set_tile(28, cursor_r, cursor_c, BLACK);
          clearing = false;
          break;
        case BLACK:
          puzzle[cursor_r][cursor_c] = WHITE;
          sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = WHITE;
          set_tile(28, cursor_r, cursor_c, WHITE);
          clearing = true;
          break;
        default:
          clearing = false;
          break;
      }
    }
    else if (key_is_down(1 << KI_B) && moved_cursor) {
      switch (puzzle[cursor_r][cursor_c]) {
        case WHITE:
        case BLACK:
        case DOT:
          if (clearing) {
            puzzle[cursor_r][cursor_c] = WHITE;
            sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = WHITE;
            set_tile(28, cursor_r, cursor_c, WHITE);
          }
          else {
            puzzle[cursor_r][cursor_c] = BLACK;
            sram_mem[(puzzle_index + 1) * 1024 + cursor_r * NUR_COLS + cursor_c] = BLACK;
            set_tile(28, cursor_r, cursor_c, BLACK);
          }
          break;
      }
    }

    if (key_hit(1 << KI_SELECT)) {
      small_tiles = !small_tiles;
      if (small_tiles) {
        REG_DISPCNT = DCNT_MODE0 | DCNT_BG2 | DCNT_BG3;
      }
      else {
        REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1;
      }
    }

    if (key_hit(1 << KI_L)) {
      return -1; // move 1 puzzle to the left
    }

    if (key_hit(1 << KI_R)) {
      return 1; // move 1 puzzle to the right
    }

    set_tile(24, cursor_r, cursor_c, CURSOR); // readd the cursor
  }
}
Exemplo n.º 12
0
void videoInit()
{
	// Blank screen for faster loading
	REG_DISPCNT = DCNT_BLANK;

	// Completely clear VRAM
	memset16(vid_mem, 0x0000, 49152);

	// BACKGROUND SETUP //
	// Set background 0 control register
	//	-Render this BG on bottom
	//  -Tile indexing starts in charblock 0
	//  -Screen-entry indexing starts in charblock 3 / screenblock 24
	//  -4 bits per pixel
	//  -512 x 512 pixels - 32 x 32 tiles - 1 x 1 screenblocks
	REG_BG0CNT = BG_PRIO(3) | BG_CBB(0) | BG_SBB(24) | BG_4BPP | BG_REG_32x32;
	
	// Set background 2 control register - Bottom text screen
	//	-Render this BG on top
	//  -Tile indexing starts in charblock 0
	//  -Screen-entry indexing starts in charblock 3 / screenblock 29
	//  -4 bits per pixel
	//  -256 x 256 pixels - 32 x 32 tiles - 1 x 1 screenblocks
	REG_BG2CNT = BG_PRIO(1) | BG_CBB(0) | BG_SBB(29) | BG_4BPP | BG_REG_32x32;

	// Set background 3 control register - Top Text Screen
	//	-Render this BG on top
	//  -Tile indexing starts in charblock 0
	//  -Screen-entry indexing starts in charblock 3 / screenblock 28
	//  -4 bits per pixel
	//  -256 x 256 pixels - 32 x 32 tiles - 1 x 1 screenblocks
	REG_BG3CNT = BG_PRIO(0) | BG_CBB(0) | BG_SBB(28) | BG_4BPP | BG_REG_32x32;

	// Load background palette
	memcpy16(&pal_bg_mem[0], g_bgPal, g_bgPalLen >> 1);

	// Load background tiles

	// Load Font tiles
	memcpy16(&tile_mem[0][g_galaxulonFont_TilesPos], g_galaxulonFont_Tiles, g_galaxulonFont_TilesLen >> 1);

	// Load other BG tiles
	memcpy16(&tile_mem[0][g_blankBG_TilesPos], g_blankBG_Tiles, g_blankBG_TilesLen >> 1);
	memcpy16(&tile_mem[0][g_assertTile_TilesPos], g_assertTile_Tiles, g_assertTile_TilesLen >> 1);
	memcpy16(&tile_mem[0][g_demo_starsTilesPos], g_demo_starsTiles, g_demo_starsTilesLen >> 1);

	// Clear Background screenmaps - set the four background screenblocks
	memset32(&se_mem[24], 0x00000000, (SBB_SIZE/4));
	
	// OAM SETUP //
	// Load OAM palette
	memcpy16(pal_obj_mem, g_spritePal, g_spritePalLen >> 1);

	// Load OAM tiles
	// Init Player sprite
	memcpy16(&tile_mem_obj[0][g_playerSpriteTilesPos], g_playerSpriteTiles, g_playerSpriteTilesLen >> 1);

	// Init bullet sprites
	memcpy16(&tile_mem_obj[0][g_bulletSpriteTilesPos], g_bulletSpriteTiles, g_bulletSpriteTilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_missileSpriteTilesPos], g_missileSpriteTiles, g_missileSpriteTilesLen >> 1);

	// Init display sprites
	memcpy16(&tile_mem_obj[0][g_bullet_selection1TilesPos], g_bullet_selection1Tiles, g_bullet_selection1TilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_bullet_selection2TilesPos], g_bullet_selection2Tiles, g_bullet_selection2TilesLen >> 1);

	// Init enemy sprites
	memcpy16(&tile_mem_obj[0][g_jellyfishTilesPos], g_jellyfishTiles, g_jellyfishTilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_mineTilesPos], g_mineTiles, g_mineTilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_sharkTilesPos], g_sharkTiles, g_sharkTilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_squidTilesPos], g_squidTiles, g_squidTilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_crabTilesPos], g_crabTiles, g_crabTilesLen >> 1);

	// Init upgrade sprites
	memcpy16(&tile_mem_obj[0][g_extraLife_TilesPos], g_extraLife_Tiles, g_extraLife_TilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_extraBomb_TilesPos], g_extraBomb_Tiles, g_extraBomb_TilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_primaryFireUp_TilesPos], g_primaryFireUp_Tiles, g_primaryFireUp_TilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_secondFireUp_TilesPos], g_secondFireUp_Tiles, g_secondFireUp_TilesLen >> 1);
	memcpy16(&tile_mem_obj[0][g_shield_TilesPos], g_shield_Tiles, g_shield_TilesLen >> 1);

	// Load Title screen logo
	memcpy16(&tile_mem_obj[0][g_galaxulon_titleTilesPos1], g_galaxulon_titleTiles, g_galaxulon_titleTilesLen >> 1);

	// Clear OAM
	oam_init(oam_mem, 128);

	// Setup Display Control Register
	//	-Video mode 0 - tiled
	//	-BG 0, BG 2, and BG 3 enabled
	//	-Enable sprites
	//	-1D sprite-mapping mode
	REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ_1D | DCNT_BG0 | DCNT_BG2 | DCNT_BG3 | DCNT_OBJ;
}
Exemplo n.º 13
0
void MainMenu()
{
	//This function brings up the main menu and has it do stuff.

	RegisterRamReset(RESET_GFX);

	REG_DISPCNT= DCNT_MODE0 | DCNT_BG0;

	tte_init_chr4c(0, 			// BG 0
		BG_CBB(0)|BG_SBB(31),	// Charblock 0; screenblock 31
		0xF000,					// Screen-entry offset
		bytes2word(1,2,0,0),	// Color attributes.
		CLR_WHITE, 			// White text
		&verdana9Font,			// Verdana 9 font
		NULL
		);

	vid_vsync();
	draw_main_menu();



	while(1){


		vid_vsync();
		mmFrame();
		key_poll();


//This code is still being worked on but it will handle what is selected on the menu.
		    if (key_hit(KEY_DOWN)){
		    	mainmenuselected++;
	           if (mainmenuselected > 3){
	        	   mainmenuselected = 3;
			   }

			    draw_main_menu();

			}else if (key_hit(KEY_UP)){
				mainmenuselected = mainmenuselected - 1;

			   if (mainmenuselected < 0){
				   mainmenuselected = 0;
			   }
			    draw_main_menu();
			}else if (key_hit(KEY_B)){

			}else if (key_hit(KEY_A)){

	          if (mainmenuselected == 0){
			  


	        	  biosdump();
	        	  vid_vsync();
	              draw_main_menu();
	
	
		   }else if (mainmenuselected == 1){
			   
			   buttontest();
			   vid_vsync();
			   draw_main_menu();
		   }else if (mainmenuselected == 2){

			   RTC_Main();
			   vid_vsync();
			   draw_main_menu();
		   }else if (mainmenuselected == 3){

			   soundtest();
			   vid_vsync();

			   draw_main_menu();
		   }

		}

	}
}