示例#1
0
文件: kernel.cpp 项目: vtlmks/kaos
void kernelmain(LoaderInfo *info)  {
	asm("mov $0x10, %ax");		// fix 64bit selectors
	asm("mov %ax, %ds");
	asm("mov %ax, %es");
	asm("mov %ax, %fs");
	asm("mov %ax, %gs");
	asm("mov %ax, %ss");
	asm("mov $0x90000, %rsp");	// temporary stack

	setupTTY(info);				// first, so that we can output text to screen et.c

	kprintf(" %s ", _kernelName);
	kprintf(_kernelVersionFormat, _kernelVersionMajor, _kernelVersionMinor, _kernelVersionPatch, KERNEL_GIT_VERSION);
	kprintf(" %s %s", _kernelBuildDate, _kernelBuildTime);
	kprintf("\n\nScreen mode %dx%d @ %d bits per pixel; %d bytes per row.\n\n", info->vesaPixelWidth, info->vesaPixelHeight, info->vesaPixelDepth, info->vesaBytesPerRow);

//	setupPaging(info);  
	setupE820(info);

	setupInterrupts();

	dev_hook_run();

	asm("jmp .;");
}
示例#2
0
void setup() {
	setupLevels();
	stateFunction = runSplash;
	setupSplash();
	setupInterrupts();
	setupSounds();
	playSound(B, (unsigned char*)main_11025Hz, MAIN_11025HZ_SIZE, 11025, 1);
}
示例#3
0
int startSounds() {
	setupInterrupts();
	setupSounds();
	
        //playSoundA(powerupsfx, POWERUPSFXLEN, POWERUPSFXFREQ, 0);
        // don't play sound B inside while loop !!!!! 
	//playSoundB(specialbgm2, SPECIALBGM2LEN, SPECIALBGM2FREQ, 1);
        //playSoundA(powerupsfx, POWERUPSFXLEN, POWERUPSFXFREQ, 0);
}
示例#4
0
//Begins Text Input
void getText(char *buffer)
{
	int FINISHED = 0;
	clearScreen();
	setupInterrupts();
	initializeSprites();
	drawKeyboard();
	playBG = TRUE;	
	while(!FINISHED)
	{
		if(playBG && !BGplaying)
        {
            // play the bg music
            DMA[2].cnt |= DMA_ON;
            REG_TM1CNT |= TM_ON;
            startBG = vblankcount;
            BGplaying = TRUE;
            DMA[2].src = flute;
        }
		checkMovement();
		//Check Input and End Function if finished
		if(!endInput)
		{
			checkSelection(buffer);
			copyShadow();
			waitForVblank();
			moveSpriteToMem();
		}
		else
		{
			DMA[2].cnt &= ~DMA_ON;
            REG_TM1CNT &= ~TM_ON;
			playBG = FALSE;
			waitForVblank();
			FINISHED = 1;
			resetVariables();
			endInput = 0;
			resetCursor();
		}
		
	}
	clearScreen();
}
示例#5
0
//-----------------------------------------------------------
// program entry point
//-----------------------------------------------------------
int main( void )
//-----------------------------------------------------------
{
	// setup things
	setupInterrupts();
	setupGraphics();
	resetBall();

	// start main loop
	while( 1 )
	{
		// update game logic
		processLogic();

		// wait for new frame
		swiWaitForVBlank();

		// update graphics
		updateGraphics();
	}
	return 0;
}
示例#6
0
//Begins Text Input
void getText(char *buffer)
{
	setRegister();
	setupInterrupts();
	initializeTiles();
	initializeSprites();
	drawKeyboard();
	playBG = TRUE;	
	while(1)
	{
		if(playBG && !BGplaying)
        {
            // play the bg music
            DMA[2].cnt |= DMA_ON;
            REG_TM1CNT |= TM_ON;
            startBG = vblankcount;
            BGplaying = TRUE;
            DMA[2].src = flute;
        }
		checkMovement();
		if(!endInput)
		{
			checkSelection(buffer);
		}
		else
		{
			DMA[2].cnt &= ~DMA_ON;
            REG_TM1CNT &= ~TM_ON;
			playBG = FALSE;
			waitForVblank();
		}
		copyShadow();
		waitForVblank();
		moveSpriteToMem();
	}
}
示例#7
0
int main() {

	setupInterrupts();
    setupSounds();

    playSoundA(titleSong, TITLESONGLEN, TITLESONGFREQ, 1);

	// Start game with splash screen
	splash();


	// Main Game Loop
	while (1) {

		oldButtons = buttons;
		buttons = BUTTONS;

		// Update player row and column
		player.bigRow = player.row + vOff;
		player.bigCol = player.col + hOff;


		switch(state) {

			case SPLASH:

				// Displays splash screen
				splash();

			break;

			case INSTRUCTIONS:

				instructions();

			break;

			case GAME:

				// Game Function holds all game logic
				game();

			break;

			case SEASONCHANGE:
				
				// Warp-like animation as player changes between seasons
				warpAnimation();

				// Change game to correct season, based on prevSeason and return to gameplay
				if (vBlankCount < 1) {
					seasonChange();
					state = GAME;
				}

			break;

			case PAUSE:

				pause();

			break;

			case LOSE:

				lose();

			break;

			case WINLEVEL:

				winLevel();

			break;

			case GAMEEND:

				gameEnd();

			break;

		}

		
		// Shadow OAM Handling
		// Player Sprite
		shadowOAM[0].attr0 = (ROWMASK & player.row) | ATTR0_SQUARE;
		shadowOAM[0].attr1 = (COLMASK & player.col) | ATTR1_SIZE16 | (ATTR1_HFLIP & (player.facing << 12));
		shadowOAM[0].attr2 = (SPRITEOFFSET16(season * 2, player.currentFrame * 2)) | ATTR2_PRIORITY2;	

		// Season Icon Sprite
		shadowOAM[1].attr0 = (ROWMASK & icon.row) | ATTR0_SQUARE;
		shadowOAM[1].attr1 = (COLMASK & icon.col) | ATTR1_SIZE16;
		shadowOAM[1].attr2 = (SPRITEOFFSET16(season * 2, 6)) | (1 << 10); // Priority 1

		REG_BG2HOFS = hOff;
        REG_BG2VOFS = vOff;

       	// Set BG1 offsets - used for snow and falling leaves
		REG_BG1HOFS = bg1HOff;
		REG_BG1VOFS = bg1VOff;
        
        //Copy the shadowOAM into the OAM
        DMANow(3, &shadowOAM, OAM, 512);

		waitForVblank();

	}

	return 0;
}
示例#8
0
文件: main.c 项目: pigs/Dog_Rescue
int main(void)
{
    while(1)
    {
		previousSpriteState = spriteState;
        pollKeys();
		enableSounds();
		setupInterrupts();


		switch(state)
		{
			case SPLASH:
			{
				REG_DISPCNTL = BG2_ENABLE | MODE3;
				fillPicture((u16 *)splashBitmap);

				if (BUTTON_PRESSED(START_BUTTON))
				{
					state = GAME;
				}
				if (BUTTON_PRESSED(SELECT_BUTTON))
				{
					state = INSTRUCTIONS;
				}
			break;
			}

			case INSTRUCTIONS:
			{
				fillPicture((u16 *)instructionsBitmap);
				if (BUTTON_PRESSED(SELECT_BUTTON))
				{
					state = SPLASH;
				}
				break;
			}
			
			case GAME:
			{

				//load tiles
				DMA_MEMORY[3].source = backgroundTiles;
				DMA_MEMORY[3].destination = &CHARBLOCK[0];
				DMA_MEMORY[3].control = 12000 | DMA_ON;

				//load map
				DMA_MEMORY[3].source = backgroundMap;
				DMA_MEMORY[3].destination = &SCREENBLOCK[27];
				DMA_MEMORY[3].control = 4096 | DMA_ON;

				//load pallette
				DMA_MEMORY[3].source = backgroundPal;
				DMA_MEMORY[3].destination = PAL_MEM;
				DMA_MEMORY[3].control = 256 | DMA_ON;


				//load the sprites into memory
				DMA_MEMORY[3].source = playerTiles;
				DMA_MEMORY[3].destination = &CHARBLOCK[4];
				DMA_MEMORY[3].control = 16384 | DMA_ON;

				DMA_MEMORY[3].source = playerPal;
				DMA_MEMORY[3].destination = SPRITE_PALETTE;
				DMA_MEMORY[3].control = 256 | DMA_ON;
			    
			    
				//Hide all sprites
				int i;
				for(i=0; i<128; i++)
				{
					OAM[i].attr0 |= ATTR0_HIDE;
				}

				//Set Mode 0 BG 0 and Enable sprites. then set up the sprites
				REG_DISPCNTL = MODE0 | BG0_ENABLE | SPRITE_ENABLE;
				REG_BG0CNT = BG_8BPP | BG_REG_64x64 | CBB(0) | SBB(27);

				REG_TM0CNT = 0;
				DMA[1].cnt = 0;

				REG_TM0D   = timerintervalA;       
				REG_TM0CNT = TIMER_ON;

				DMA[1].src = bgsound;
				DMA[1].dst = REG_FIFO_A;
				DMA[1].cnt = DMA_ON | START_ON_FIFO_EMPTY |
							 DMA_32 | DMA_REPEAT |
							 DMA_DESTINATION_FIXED;

				startA = vblankcountA;

				while(1){

					shadowOAM[0].attr0 = (playerRow & MASKROW) | ATTR0_TALL | ATTR0_REGULAR | ATTR0_8BPP;
					shadowOAM[0].attr1 = (playerCol & MASKCOL)| ATTR1_SIZE32;
					shadowOAM[0].attr2 = (SPRITEOFFSET16(0,0));

					shadowOAM[1].attr0 = badguyRow | ATTR0_TALL | ATTR0_REGULAR | ATTR0_8BPP;
					shadowOAM[1].attr1 = badguyCol | ATTR1_SIZE32;
					shadowOAM[1].attr2 = (SPRITEOFFSET16(0,8));

					pollKeys();
					bigRow = playerRow + vOff;
					bigCol = playerCol + hOff;

				switch(spriteState)
				{
					case STILL:
					{
						shadowOAM[0].attr2 = (SPRITEOFFSET16(0,0));
						break;
					}

					case MOVING:
					{
						if((walkCounter%2)==1)
							shadowOAM[0].attr2 = (SPRITEOFFSET16(0,4));
						else if((walkCounter%2==0))
						{
						shadowOAM[0].attr2 = (SPRITEOFFSET16(0,0)); 
						}
						break;
					}

				}	
				

					if(BUTTON_HELD(A_BUTTON) && BUTTON_HELD(B_BUTTON))
					{
						//load tiles
						DMA_MEMORY[3].source = cheatbackgroundTiles;
						DMA_MEMORY[3].destination = &CHARBLOCK[0];
						DMA_MEMORY[3].control = 11456 | DMA_ON;

						//load map
						DMA_MEMORY[3].source = cheatbackgroundMap;
						DMA_MEMORY[3].destination = &SCREENBLOCK[27];
						DMA_MEMORY[3].control = 4096 | DMA_ON;

						//load pallette
						DMA_MEMORY[3].source = cheatbackgroundPal;
						DMA_MEMORY[3].destination = PAL_MEM;
						DMA_MEMORY[3].control = 256 | DMA_ON;
					}
					if (BUTTON_HELD(RIGHT_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						if(collisionmapBitmap[((bigRow+playerHeight)*collMapSize)+(bigCol+playerCVel+playerWidth)]==WHITE)
						{
							if(playerCol<(SCREEN_WIDTH-(playerWidth+5))){
								playerCol+=playerCVel;
							}
							else if(hOff<(collMapSize-SCREEN_WIDTH))
							{
								hOff+=playerCVel;
							}
						}
					}
					if (BUTTON_HELD(LEFT_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						if(collisionmapBitmap[((bigRow+playerHeight)*collMapSize)+(bigCol+playerCVel)]==WHITE)
						{
							if(playerCol>(0))
							{
								playerCol-=playerCVel;
							}
							else if(hOff>(SCREEN_WIDTH-collMapSize))
							{
								hOff-=playerCVel;
							}
						}
					}
					if (BUTTON_HELD(UP_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						//Check collision and move
						if((collisionmapBitmap[(((bigRow-playerRVel)*collMapSize)+(bigCol+playerWidth))]==WHITE)&&
							(collisionmapBitmap[(((bigRow-playerRVel)*collMapSize)+(bigCol))]==WHITE))
						{
							if(playerRow>30)
							{
								playerRow-=playerRVel;
							}
							else if(vOff>0)
							{
								vOff-=playerRVel;
							}
						}
						
					}
					if (BUTTON_HELD(DOWN_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						//Check collision and move
						if((collisionmapBitmap[(((bigRow+playerHeight+playerRVel)*collMapSize)+(bigCol+playerWidth))]==WHITE)&&
							(collisionmapBitmap[(((bigRow+playerHeight+playerRVel)*collMapSize)+(bigCol))]==WHITE))
						{

							if(playerRow<(SCREEN_HEIGHT-(playerHeight)))
							{
								playerRow+=playerRVel;
							}
							else if(vOff<(collMapSize-SCREEN_HEIGHT))
							{
								vOff+=playerRVel;
							}
						if((playerRow > 440) && (playerCol > 464))
						{
							state = WIN;
						}
						}


					}
					if (BUTTON_PRESSED(START_BUTTON))
					{
							REG_TM1CNT = 0;
							DMA[2].cnt = 0;
						
							REG_TM1D   = timerintervalB;       
							REG_TM1CNT = TIMER_ON;

							DMA[2].src = bark;
							DMA[2].dst = REG_FIFO_B;
							DMA[2].cnt = DMA_ON | START_ON_FIFO_EMPTY |
										 DMA_32 | DMA_REPEAT |
										 DMA_DESTINATION_FIXED;

							startB = vblankcountB;
					}
					if (BUTTON_PRESSED(SELECT_BUTTON))
					{
						//waitForNoKey();
						state = PAUSE;
					}
					
					waitForVBlank();
					OAM[0] = shadowOAM[0];
					OAM[1] = shadowOAM[1];

					REG_BG0HOFS = hOff;
					REG_BG0VOFS = vOff;

				}

			}

				case WIN:
				{
					while(1);
				}

				case PAUSE:
				{
					if(BUTTON_PRESSED(SELECT_BUTTON))
					{
						state=GAME;
					}
				}

		}

	}

    return 0;
}