void main_test_display(){ UART_Start(); // initialize UART UART_PutChar(0x81); // init connection; set to 16x12 image struct disp_grid_81 disp; disp_grid_init(&disp,0x3F); // init our display grid matrix to white disp_grid_transmit(&disp); struct tic_tac_ai tta; tta_init(&tta,4,3,false,true); //first bool for player 1, second bool for player 2. true means is AI disp_grid_init_ttc(&disp, tta.game.grid); disp_grid_draw_tic(&disp,24,1,0x27); // draw tic disp_grid_draw_win(&disp,27,9,1); // draw tic disp_grid_draw_xia(&disp,26,16,0x30); // draw xia disp_grid_transmit(&disp); }
void main_play_tta_ai(){ LCD_Start(); // initialize lcd LCD_ClearDisplay(); UART_Start(); // initialize UART UART_PutChar(0x81); // init connection; set to 16x12 image struct disp_grid_81 disp; disp_grid_init(&disp,0x3F); // init our display grid matrix to white disp_grid_transmit(&disp); int x,y,z; uint8 Values; struct tic_tac_ai tta; tta_init(&tta,4,3,true,false); //first bool for player 1, second bool for player 2 disp_grid_init_ttc(&disp, tta.game.grid); disp_grid_draw_xia(&disp,26,16,0x30); // draw xia disp_grid_transmit(&disp); while (tta.game.game_not_won == 0){ Values = read_from_8255(Values); //read and print if (Values >= 0 && Values <= 63){ //integer value z = Values / 16; x = Values % 4; //get row value y = Values / 4 - z*4; // // LCD_ClearDisplay(); // LCD_PrintNumber(Values); // LCD_PrintString(" x"); // LCD_PrintNumber(x); // LCD_PrintString(" y"); // LCD_PrintNumber(y); // LCD_PrintString(" z"); // LCD_PrintNumber(z); } tta_step(&disp,&tta,x,y,z); //increment a turn disp_grid_transmit(&disp); } LCD_ClearDisplay(); LCD_PrintString("GAME OVER!"); disp_grid_draw_win(&disp,27,9,tta.game.player); // draw tic disp_grid_transmit(&disp); }
void main_flashing_tta(){ // this is the function compatible with the cap sensor input. does not use 8051; connect directly LCD_Start(); // initialize lcd LCD_ClearDisplay(); UART_Start(); // initialize UART UART_PutChar(0x81); // init connection; set to 16x12 image struct disp_grid_81 disp; disp_grid_init(&disp,0x3F); // init our display grid matrix to white disp_grid_transmit(&disp); struct tic_tac_ai tta; tta_init(&tta,4,3,false,true); //first bool for player 1, second bool for player 2. true means is AI disp_grid_init_ttc(&disp, tta.game.grid); disp_grid_draw_xia(&disp,26,16,0x30); // draw xia disp_grid_transmit(&disp); int x,y,z, count; uint8 Values; uint8 Values_prev; Values_prev = Pin0_Read(); x = 0; y = 0; z = 0; //test value count = 0; uint8 red_flash; //the temporary location flasher uint8 other_val; other_val = disp_grid_ttc_getval(&disp,z*16 + y*4 + x); // get the nonred val red_flash = 0x30; //map to color red tta_step(&disp,&tta,x,y,z); //AI Increment also while (tta.game.game_not_won == 0){ // Values = read_from_8255(Values); //read and print LCD_ClearDisplay(); LCD_Position(0,0); //move back to top row Values = Pin0_Read(); //next, read a new value LCD_PrintString("P0: "); LCD_PrintNumber(Values); //print value I am getting if (Values != Values_prev){ Values_prev = Values; //we don't want nonconsect if (Values != 0){ if (Values == 32){ tta_step(&disp,&tta,x,y,z); //increment a turn tta_step(&disp,&tta,x,y,z); //AI Increment also other_val = disp_grid_ttc_getval(&disp,z*16 + y*4 + x); // get the nonred val } else{ disp_grid_ttc_place_value(&disp,z*16 + y*4 + x,other_val); if (Values == 16 && y != 0){ // up y--; } else if (Values == 8 && y != 3){ // down y++; } else if (Values == 4 && x != 0){ // left x--; } else if (Values == 2 && x != 3){ // right x++; } else if (Values == 1){ // level shift z++; z = z % 4; } other_val = disp_grid_ttc_getval(&disp,z*16 + y*4 + x); // get the nonred val } } } if (count == 0){ //decide print count = 1; disp_grid_ttc_place_value(&disp,z*16 + y*4 + x,red_flash); } else{ count = 0; disp_grid_ttc_place_value(&disp,z*16 + y*4 + x,other_val); } disp_grid_transmit(&disp); } LCD_ClearDisplay(); LCD_PrintString("GAME OVER!"); }
void main_flashing_tta_psoc(){ // this is the function compatible with the cap sensor input. with 8051 interrupts LCD_Start(); // initialize lcd LCD_ClearDisplay(); UART_Start(); // initialize UART UART_PutChar(0x81); // init connection; set to 16x12 image struct disp_grid_81 disp; disp_grid_init(&disp,0x3F); // init our display grid matrix to white disp_grid_transmit(&disp); struct tic_tac_ai tta; tta_init(&tta,4,3,false,true); //first bool for player 1, second bool for player 2. true means is AI disp_grid_init_ttc(&disp, tta.game.grid); disp_grid_draw_tic(&disp,24,1,0x27); // draw tic disp_grid_draw_xia(&disp,26,16,0x30); // draw xia disp_grid_transmit(&disp); int x,y,z, count; uint8 Values; uint8 Values_prev; uint8 current; Values_prev = 0; x = 0; y = 0; z = 0; //test value count = 0; uint8 red_flash; //the temporary location flasher uint8 other_val; other_val = disp_grid_ttc_getval(&disp,z*16 + y*4 + x); // get the nonred val red_flash = 0x30; //map to color red while (tta.game.game_not_won == 0){ LCD_ClearDisplay(); LCD_Position(1,0); //move to bot row LCD_PrintString("LAST:"); //first, we print last value LCD_PutChar(Values_prev); //print ascii value LCD_PrintString(" HEX: "); LCD_PrintNumber(Values_prev); //print value I am getting current = Pin3_Read(); //next, read a new value LCD_Position(0,0); //move back to top row LCD_PrintString("CURR:"); LCD_PutChar(current); //print ascii value LCD_PrintString(" HEX: "); LCD_PrintNumber(current); //print value I am getting waiter(3); if (current != 255) { Values = current; // update values as last non Values_prev = Values; } if (Values != 0){ if (Values == 54){ if (tta.game.grid[z*16 + y*4 + x] == 0){ // make sure we can place there tta_step(&disp,&tta,x,y,z); //increment a turn disp_grid_transmit(&disp); tta_step(&disp,&tta,x,y,z); //AI Increment also other_val = disp_grid_ttc_getval(&disp,z*16 + y*4 + x); // get the nonred val } } else{ disp_grid_ttc_place_value(&disp,z*16 + y*4 + x,other_val); if (Values == 53 && y != 0){ // up y--; } else if (Values == 52 && y != 3){ // down y++; } else if (Values == 51 && x != 0){ // left x--; } else if (Values == 50 && x != 3){ // right x++; } else if (Values == 49){ // level shift z++; z = z % 4; } other_val = disp_grid_ttc_getval(&disp,z*16 + y*4 + x); // get the nonred val } Values = 0; // reset values; count = 0; } if (count == 0){ //decide print count = 1; disp_grid_ttc_place_value(&disp,z*16 + y*4 + x,red_flash); disp_grid_transmit(&disp); } // else{ // count = 0; // disp_grid_ttc_place_value(&disp,z*16 + y*4 + x,other_val); // disp_grid_transmit(&disp); // } } LCD_ClearDisplay(); LCD_PrintString("GAME OVER!"); disp_grid_draw_win(&disp,27,9,tta.game.player); // draw tic disp_grid_transmit(&disp); }
int music_init(void) { pspTime tm; cache_init(); xrRtcGetCurrentClockLocalTime(&tm); srand(tm.microseconds); xr_lock_init(&music_l); #ifdef ENABLE_MPC mpc_init(); #endif #ifdef ENABLE_WAV wav_init(); #endif #ifdef ENABLE_TTA tta_init(); #endif #ifdef ENABLE_APE ape_init(); #endif #ifdef ENABLE_MP3 mp3_init(); #endif #ifdef ENABLE_FLAC flac_init(); #endif #ifdef ENABLE_OGG ogg_init(); #endif #ifdef ENABLE_WMA wmadrv_init(); #endif #ifdef ENABLE_WAVPACK wv_init(); #endif #ifdef ENABLE_AT3 at3_init(); #endif #ifdef ENABLE_M4A m4a_init(); #endif #ifdef ENABLE_AAC aac_init(); #endif #ifdef ENABLE_AA3 aa3_init(); #endif memset(&g_list, 0, sizeof(g_list)); g_list.first_time = true; g_shuffle.first_time = true; stack_init(&played); g_music_thread = xrKernelCreateThread("Music Thread", music_thread, 0x12, 0x10000, 0, NULL); if (g_music_thread < 0) { return -EBUSY; } xrKernelStartThread(g_music_thread, 0, 0); return 0; }
int music_init(void) { u32 seed; cache_init(); seed = sctrlKernelRand(); if (seed == 0x8002013A) { pspTime tm; sceRtcGetCurrentClockLocalTime(&tm); seed = tm.microseconds; } srand(seed); xr_lock_init(&music_l); #ifdef ENABLE_MPC mpc_init(); #endif #ifdef ENABLE_WAV wav_init(); #endif #ifdef ENABLE_TTA tta_init(); #endif #ifdef ENABLE_APE ape_init(); #endif #ifdef ENABLE_MP3 mp3_init(); #endif #ifdef ENABLE_FLAC flac_init(); #endif #ifdef ENABLE_OGG ogg_init(); #endif #ifdef ENABLE_WMA wmadrv_init(); #endif #ifdef ENABLE_WAVPACK wv_init(); #endif #ifdef ENABLE_AT3 at3_init(); #endif #ifdef ENABLE_M4A m4a_init(); #endif #ifdef ENABLE_AAC aac_init(); #endif #ifdef ENABLE_AA3 aa3_init(); #endif musiclist_init(&g_music_list); memset(&g_list, 0, sizeof(g_list)); g_list.first_time = true; stack_init(&g_played); g_music_thread = sceKernelCreateThread("Music Thread", music_thread, 0x12, 0x10000, 0, NULL); if (g_music_thread < 0) { return -EBUSY; } sceKernelStartThread(g_music_thread, 0, 0); return 0; }