Esempio n. 1
0
int main(void) {
	titleScreen();
	initBoard();
	drawBoard();
	VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL3, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 20), 32, 0, 5, 3);
	while(1) {
		VDP_waitVSync();
	}
	return 0;
}
Esempio n. 2
0
void showBmp ( u16 pal, struct genresTiles *grt, u16 tile, VDPPlan plan, u16 x, u16 y, u8 pal_steps )
{
	SYS_disableInts();
	VDP_loadTileData ( grt->tiles, tile, grt->width * grt->height, 0 );
	SYS_enableInts();

	SYS_disableInts();
	VDP_fillTileMapRectInc ( plan, TILE_ATTR_FULL ( pal, 1, 0, 0, tile ), x, y, grt->width, grt->height );
	SYS_enableInts();
}
Esempio n. 3
0
void drawBoard() {
	int x, y;
	char score_string[11];
	for (y = 0; y != BOARD_Y; y++) {
		for (x = 0; x != BOARD_X; x++) {
			if (board[y][x].id) {
				if (board[y][x].selected)
					VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL2, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT);
				else
					VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL1, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT);
			} else {
				VDP_clearTileMapRect(VDP_PLAN_A, CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT);
			}
		}
	}
	VDP_drawText("Level 1", 31, 3);
	//VDP_drawText("Goals:", 32, 5);
	//VDP_drawText("0 / 0", 32, 6);
	VDP_drawText("Score:", 30, 26);
	intToStr((s32)score, score_string, 1);
	VDP_clearTileMapRect(VDP_PLAN_A, 30, 27, 10, 1);
	VDP_drawText(score_string, 30, 27);
	VDP_updateSprites();
}
Esempio n. 4
0
void HUD_updateStatusView(u8 joy, u8 bA, u8 bB, u8 bC, u8 bStart, u8 statusCode){
	u8 i,j;
	u8 channel;
	char status[20];

	//for each line
	for (j=0;j<9;j++){
		if (statusCode & statusCodes[j]){
			drawStatusMsg(joy,j);
		}
	}

	// u16 x = X0 + (joy * (WIDTH_TILES/2));
	// if (joy) x--;
	// u16 x = (joy * ((WIDTH_TILES-(HORIZONTAL_MARGIN*2)) / 2)) + (HORIZONTAL_MARGIN);
	u16 x = leftEdge(joy);
	u16 y = Y_STATUS;

	if (bStart && statusCode){
		bA = bB = bC = 0;
	}
	else{
		if (bA > 0) bA = 1;
		if (bB > 0) bB = 1;
		if (bC > 0) bC = 1;
	}

	//draw either grey or white circles to represent the fingering buttons
	VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bA), x+X_BUTTONS, y+Y_BUTTONS);
	VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bB), x+X_BUTTONS+2, y+Y_BUTTONS);
	VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bC), x+X_BUTTONS+4, y+Y_BUTTONS);

	char solfege[3];
	u8 mode = modeList[joy][keyIndex[joy]];
	u8 scalePitch = Instrument_buttonsToScalePitch(bA, bB, bC) % 7;
	u8 truePitch = SCALES[mode][scalePitch];
	switch (scalePitch){
		case 0:
			strcpy(solfege, "Do");
			break;
		case 1:
			strcpy(solfege, (truePitch == 1) ? "Ra" : "Re");
			break;
		case 2:
			strcpy(solfege, (truePitch == 3) ? "Me" : "Mi");
			break;
		case 3:
			strcpy(solfege, (truePitch == 6) ? "Fi" : "Fa");
			break;
		case 4:
			strcpy(solfege, (truePitch == 8) ? "Si" : (truePitch == 6) ? "Se" : "Sol");
			break;
		case 5:
			strcpy(solfege, (truePitch == 10) ? "Li" : (truePitch == 8) ? "Le" : "La");
			break;
		case 6:
			strcpy(solfege, (truePitch == 10) ? "Te" : "Ti");
			break;
		default:
			strcpy(solfege, "");
			break;
	}
	drawText(solfege, x+X_BUTTONS+6, y+Y_BUTTONS, 0, 3);

	// VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+2), x+X_NOTE, 25, 1, 2);

	//draw musical note
	if (playing[joy]){
		VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+2), x+X_NOTE, Y_NOTE, 1, 2);
	}
	else {
		VDP_clearTileMapRect(APLAN, x+X_NOTE, Y_NOTE, 1, 2);
	}

}
Esempio n. 5
0
void titleScreen() {
	snowflake snowflakes[TITLE_SCREEN_SNOWFLAKES];
	SpriteDef sfdefs[TITLE_SCREEN_SNOWFLAKES];
	
	VDP_resetScreen();
	VDP_resetSprites();

	// Load Swirls
	VDP_loadTileData(swirls, TILE_USERINDEX, 20, TRUE);
	VDP_loadTileData(title_screen, TILE_USERINDEX + 20, 15, TRUE);
	VDP_loadTileData(swirl_spr, TILE_USERINDEX + 35, 20, TRUE);
	VDP_setPalette(PAL1, swirl_pal);
	VDP_setPalette(PAL2, sel_pal);
	VDP_setPalette(PAL3, ts_pal);
	
	JOY_init();
	JOY_setEventHandler(titleHandler);
	
	ImageAsset* title = getImage(titlbg);
	VDP_setPalette(PAL0, title->palette);
	VDP_loadTileData(title->tiles, TILE_USERINDEX + 55, (title->xTiles * title->yTiles), TRUE);
	VDP_fillTileMapRectInc(VDP_PLAN_B, TILE_ATTR_FULL(PAL0, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 55), 0, 0, title->xTiles, title->yTiles);
	MEM_free( title );
	
	VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL3, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 20), 18, 3, 5, 3);
	VDP_drawText("Mega Swirl",  1, 7);
	VDP_drawText("Testing Demo", 1, 8);
	VDP_drawText(VERSION_STRING, 1, 9);
	
	VDP_drawText("Music from Deflemask by", 1, 11);
	VDP_drawText("Delek", 1, 12);
	
	VDP_drawText("Featuring artwork by", 1, 14);
	VDP_drawText("Radioactivemantaray", 1, 15);
	
	VDP_drawText("- Press Start to Play -", 1, 21);
	VDP_drawText(BUILD_DATE, 1, 24);

	u8 selected_swirl;
	for(int i = 0; i != TITLE_SCREEN_SNOWFLAKES; i++) {
		snowflakes[i].startedAt = 
		snowflakes[i].startDelay =
		snowflakes[i].fallRate =
		snowflakes[i].swirltype =
		0;
		
		sfdefs[i].posx =
		sfdefs[i].posy =
		sfdefs[i].tile_attr =
		sfdefs[i].size =
		sfdefs[i].link =
		0;
		
		selected_swirl = (custrand() % 4);
		snowflakes[i].swirltype = selected_swirl; // Select one of four swirl types
		snowflakes[i].startDelay = ((custrand() % 3000) + 1) / 300; // Select between a 1-10 second delay (300 ticks per second)
		snowflakes[i].startedAt = getTick(); // Time when this snowflake was created 
		snowflakes[i].fallRate = (custrand() % 2) + 1; // Select how fast this snowflake should fall to the bottom of the screen
		sfdefs[i].posx = (custrand() % 320); // Select X position for this swirl
		sfdefs[i].posy = -16; // Start it off screen
		
		sfdefs[i].size = SPRITE_SIZE(2, 2);
		sfdefs[i].tile_attr = TILE_ATTR_FULL(PAL1, PRIORITY_HIGH, FALSE, FALSE, TILE_USERINDEX + 35 + (4 * selected_swirl)); // This will need to be changed as we need tiles arranged for sprites
		if(i != 0) {
			sfdefs[i - 1].link = i;
		}
	}
	VDP_setSpritesDirect(0, sfdefs, TITLE_SCREEN_SNOWFLAKES);

	Z80_loadDriver(Z80_DRIVER_VGM, 1);
	Z80_requestBus(1);
	YM2612_enableDAC();
	Z80_releaseBus();
	SND_startPlay_VGM(muz_title);

	while (waitflag == FALSE) {
		
		for(int i = 0; i != TITLE_SCREEN_SNOWFLAKES; i++) {
			
			if(getTick() - snowflakes[i].startedAt >= snowflakes[i].startDelay) {
				
				if(sfdefs[i].posy != 240) {
					sfdefs[i].posy = sfdefs[i].posy + snowflakes[i].fallRate;
				} else {
					selected_swirl = (custrand() % 4);
					snowflakes[i].startDelay = ((custrand() % 3000) + 1) / 300;
					snowflakes[i].startedAt = getTick();
					snowflakes[i].fallRate = (custrand() % 2) + 1;
					sfdefs[i].posx = (custrand() % 320);
					sfdefs[i].posy = -16;
				}
				
			}
			
			VDP_setSpritesDirect(0, sfdefs, TITLE_SCREEN_SNOWFLAKES);
		}
		
	}

	waitflag = FALSE;

	srand(GET_HVCOUNTER);
	VDP_clearPlan(APLAN, FALSE);
	JOY_setEventHandler(joyHandler);

	ImageAsset* test = getImage(swlspace);
	VDP_setPalette(PAL0, test->palette);
	VDP_loadTileData(test->tiles, TILE_USERINDEX + 55, (test->xTiles * test->yTiles), TRUE);
	VDP_fillTileMapRectInc(VDP_PLAN_B, TILE_ATTR_FULL(PAL0, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 55), 0, 0, test->xTiles, test->yTiles);
	MEM_free( test );
	
	SND_stopPlay_VGM();
}