#include	"global.h"
#include	"title.h"
#include	"main.h"
#include	"sprite1.h"
#include	"stage.h"


/* plπ`ζ */
unsigned short map1[] = {  0, 1, 2, 3, 4, 5,
						  20,21,22,23,24,25,
						  40,41,42,43,44,45,
						  60,61,62,63,64,65
						};
unsigned short map2[] = {  6, 7, 8, 9,10,11,
						  26,27,28,29,30,31,
						  46,47,48,49,50,51,
						  66,67,68,69,70,71
						};
unsigned short map3[] = { 12,13,14,15,16,17,
						  32,33,34,35,36,37,
						  52,53,54,55,56,57,
						  72,73,74,75,76,77
						};
unsigned short map4[] = {  80, 81, 82, 83, 84, 85,
						  100,101,102,103,104,105,
						  120,121,122,123,124,125,
						  140,141,142,143,144,145
						};
unsigned short map5[] = {  86, 87, 88, 89, 90, 91,
						  106,107,108,109,110,111,
						  126,127,128,129,130,131,
						  146,147,148,149,150,151
						};
unsigned short map6[] = {  92, 93, 94, 95, 96, 97,
						  112,113,114,115,116,117,
						  132,133,134,135,136,137,
						  152,153,154,155,156,157
						};
unsigned short map7[] = { 160,161,162,163,164,165,
						  180,181,182,183,184,185,
						  200,201,202,203,204,205,
						  220,221,222,223,224,225
						};
unsigned short map8[] = { 166,167,168,169,170,171,
						  186,187,188,189,190,191,
						  206,207,208,209,210,211,
						  226,227,228,229,230,231
						};
unsigned short map9[] = { 172,173,174,175,176,177,
						  192,193,194,195,196,197,
						  212,213,214,215,216,217,
						  232,233,234,235,236,237
						};
unsigned short map10[] = { 58,59,78,79 };	/* Η */
unsigned short map11[] = { 18 };	/* Η */	
unsigned short map12[] = { 98,118,138,158 };	/* εg */
unsigned short map13[] = { 99,119,139,159 };	/* εg */
unsigned short map14[] = { 246,247,248,249,250,251,252,253,254,255 };	/* εg */
unsigned short map15[] = { 266,267,268,269,270,271,272,273,274,275 };	/* εg */
unsigned short map16[] = { 246,247,248,249,250,251,252,253,254 };	/* εg */
unsigned short map17[] = { 267,268,269,270,271,272,273,274,275 };	/* εg */
unsigned short map18[] = { 118,138,158 };	/* εg */
unsigned short map20[] = { 99,119,139 };	/* εg */

unsigned short map21[] = { 240,241,242,243,244,245,		/* ¬g */
						   260,261,262,263,264,265,
						   280,281,282,283,284,285
						 };

unsigned short map22[] = { 286,287,288,289,290,291,292,293,294,295 };	/* Η */
unsigned short map23[] = { 198,199,218,219,238,239 };	/* Η */


void	draw(void);
void	title_draw(void);
void	stage_draw(void);
void	main_draw(void);
void	ending_draw(void);
void	draw_setup(void);


void	draw( void )
{
	wwc_set_color_mode(COLOR_MODE_4COLOR);
	wwc_palette_set_color(0,0,0x0fff);
	wwc_palette_set_color(0,1,0x000f);
	wwc_palette_set_color(0,2,0x0ff0);
	wwc_palette_set_color(0,3,0x0522);

/*	palette_set_color(0,0x7410);
*/
	font_set_colordata(0,20*16,bmp_sprite1);
	screen_fill_char(SCREEN2,0,0,28,18,511);

		/* plπ`ζ */
	screen_set_char( SCREEN2, x1, y1, 6, 4, map1 );
	screen_set_char( SCREEN2, x2, y2, 6, 4, map2 );
	screen_set_char( SCREEN2, x3, y3, 6, 4, map3 );
	screen_set_char( SCREEN2, x4, y4, 6, 4, map4 );
	screen_set_char( SCREEN2, x5, y5, 6, 4, map5 );
	screen_set_char( SCREEN2, x6, y6, 6, 4, map6 );
	screen_set_char( SCREEN2, x7, y7, 6, 4, map7 );
	screen_set_char( SCREEN2, x8, y8, 6, 4, map8 );
/*	screen_set_char( SCREEN2, 17, 12, 6, 4, map9 );*/

	for(j=0;j<18;j+=2){				/* Ηπ`ζ1 */
		for(i=24;i<28;i+=2){
			screen_set_char( SCREEN2, i, j, 2, 2, map10 );
		}
		for(i=0;i<4;i+=2){
			screen_set_char( SCREEN2, i, j, 2, 2, map10 );
		}
	}

	for(i=4;i<15;i+=10) screen_set_char( SCREEN2, i, 17, 10, 1, map22 );
	for(i=4;i<9;i+=2) screen_set_char( SCREEN2, i, 0, 2, 3, map23 );
	for(i=16;i<23;i+=2) screen_set_char( SCREEN2, i, 0, 2, 3, map23 );

		/* εgπ`ζ */
	screen_set_char( SCREEN2,  4,  3, 1, 4, map12 );
	screen_set_char( SCREEN2, 23, 13, 1, 4, map13 );
	for(j=7;j<14;j+=3) screen_set_char( SCREEN2,  4, j, 1, 3, map18 );
	for(j=4;j<11;j+=3) screen_set_char( SCREEN2,  23, j, 1, 3, map20 );
	screen_set_char( SCREEN2, 14,  3,10, 1, map14 );
	screen_set_char( SCREEN2,  4, 16,10, 1, map15 );
	screen_set_char( SCREEN2,  5,  3, 9, 1, map16 );
	screen_set_char( SCREEN2,  14, 16, 9, 1, map17 );

		/* ¬gπ`ζ */
	screen_set_char( SCREEN2, 10, 0, 6, 3, map21 );
	text_put_numeric( 12, 1, 3, 0,time_count);

}



void	title_draw(void)
{
	
	wwc_set_color_mode(COLOR_MODE_4COLOR);
	wwc_palette_set_color(0,0,0x0fff);
	wwc_palette_set_color(0,1,0x000f);
	wwc_palette_set_color(0,2,0x0ff0);
	wwc_palette_set_color(0,3,0x0119);
/*	palette_set_color(0,0x7230);
*/
	font_set_colordata(0,28*18,bmp_title);
	
	for(j=0;j<18;j++){
		for(i=0;i<28;i++){
			screen_fill_char(SCREEN2,i,j,1,1,i+28*j);
		}
	}

	text_put_string(9,13,"PRESS TO A");
}

void	stage_draw(void)
{
	
/*	palette_set_color(0,0x7230);
*/
	wwc_set_color_mode(COLOR_MODE_4COLOR);
	wwc_palette_set_color(0,0,0x0fff);
	wwc_palette_set_color(0,1,0x000f);
	wwc_palette_set_color(0,2,0x0ff0);
	wwc_palette_set_color(0,3,0x0f00);

	font_set_colordata(0,28*18,bmp_stage);
	
	for(j=0;j<18;j++){
		for(i=0;i<28;i++){
			screen_fill_char(SCREEN2,i,j,1,1,i+28*j);
		}
	}

	text_put_numeric( 16, 10, 2, 0, stage_count );
}

void	main_draw(void)
{
/*	palette_set_color(0,0x7410);
*/
	wwc_set_color_mode(COLOR_MODE_4COLOR);
	wwc_palette_set_color(0,0,0x0fff);
	wwc_palette_set_color(0,1,0x000f);
	wwc_palette_set_color(0,2,0x0ff0);
	wwc_palette_set_color(0,3,0x0722);

	font_set_colordata(0,28*18,bmp_main);
	
	for(j=0;j<18;j++){
		for(i=0;i<28;i++){
			screen_fill_char(SCREEN2,i,j,1,1,i+28*j);
		}
	}
	text_put_string( 10, 6,"EGAMEX^[g" );
	text_put_string( 10, 8,"PUSH A{^" );
	text_put_string( 10, 11,"EΫθΘX^[g" );
	text_put_string( 10, 13 ,"PUSH B{^" );

}

void	ending_draw(void)
{
	text_put_string( 6,7,"ALL CLEAR" );
	text_put_string( 4,10,"THANK YOU FOR PLAYING" );
	sys_wait(225);
	text_screen_init();

	text_put_string( 10,10,"STAFF" );
	sys_wait(225);
	text_screen_init();

	text_put_string( 5,10,"ιζAvOATEhAOtBbN" );
	text_put_string( 10,12,"ΰΊ@^κ" );
	sys_wait(225);
	text_screen_init();

	text_put_string( 8,10,"vOβ" );
	text_put_string( 10,12,"«@«χ" );
	sys_wait(225);
	text_screen_init();

	text_put_string( 8,10,"OtBbNβ" );
	text_put_string( 10,12,"sμ@Rΐq" );
	sys_wait(225);
	text_screen_init();

	text_put_string( 8,4,"XyVTNX" );
	text_put_string( 10,7,"Ι‘@Mj" );
	text_put_string( 10,9,"Vμ@SO" );
	text_put_string( 10,11,"δγ@Φi" );
	sys_wait(225);
	text_screen_init();

	text_put_string( 5,10,"AND ALL DEA TEACHERS" );
	text_put_string( 5,12,"AND ALL DEA STUDENTS" );
	sys_wait(225);
	text_screen_init();

	text_put_string( 12,10,"END" );
	sys_wait(750);

}

void	draw_setup(void)
{
		if(wwc_get_hardarch()==HARDARCH_WS){
		text_screen_init();
		text_put_string( 2,8,"X[J[ζI");
		key_wait();
		return;
	}




	display_control(6);
	text_screen_init();

	
}  
