void main(void) { uint16_t i ; Init_System(); // 系统初始化 // _EINT(); // 开总中断 //__bis_SR_register(LPM3_bits); //进入LPM3 P1OUT |= BIT0; P8OUT |= BIT1; Init_Key(); while(1) { if( Read_Key1() ) { P1OUT ^= BIT0; } if(Read_Key2()) { P8OUT ^= BIT1; } } }
void NewPrompter() { char* buttons[MAX_CONTROL]; char tempstring[MAX_CONTROL][MAX_TEMP_STRING]; char* tempkeystring[MAX_CONTROL+2]; tempkeystring[0] = "WEAPON"; tempkeystring[1] = "ENTER"; tempkeystring[2] = "ESC"; tempkeystring[3] = "USE"; tempkeystring[4] = "MOVE"; tempkeystring[5] = "MAP"; tempkeystring[6] = "RUN"; tempkeystring[7] = "FIRE"; tempkeystring[8] = "M_LEFT"; tempkeystring[9] = "M_RIGHT"; //tempkeystring[10] = "222"; //tempkeystring[11] = "266"; //tempkeystring[12] = "333"; buttons[0] = "ANALOG "; buttons[1] = "START "; buttons[2] = "SELECT "; buttons[3] = "CROSS "; buttons[4] = "DPAD "; buttons[5] = "TRIANGLE "; buttons[6] = "SQUARE "; buttons[7] = "CIRCLE "; buttons[8] = "L_TRIG "; buttons[9] = "R_TRIG "; //buttons[10] = "CPU_CLOCK"; control_bef_ctl = 0; pgScreenFrame(2,0); pgFillvram(0); pgScreenFlipV(); while (1) { pgFillvram(0); int i = 0; int die = 0; int col; for (i=0; i<MAX_CONTROL; i++) { if (d_controls[i] == CKEY_WEAPON) die = 0; else if (d_controls[i] == KEY_ENTER) die = 1; else if (d_controls[i] == KEY_ESCAPE) die = 2; else if (d_controls[i] == ' ') die = 3; else if (d_controls[i] == CKEY_MOVE) die = 4; else if (d_controls[i] == KEY_TAB) die = 5; else if (d_controls[i] == KEY_RSHIFT) die = 6; else if (d_controls[i] == KEY_RCTRL) die = 7; else if (d_controls[i] == ',') die = 8; else if (d_controls[i] == '.') die = 9; else if (d_controls[i] == 222) die = 10; else if (d_controls[i] == 266) die = 11; else if (d_controls[i] == 333) die = 12; col = rgb2col(255,255,255); if (i==d_clist_curpos) { col = rgb2col(255,0,0); } sprintf(tempstring[i], "%s = %s",buttons[i],tempkeystring[die]); mh_print(5, ((i + 2) * 20), tempstring[i], col, 0, 0); } if (d_clist_curpos != 10) { mh_print(5,255,"X: Exit | O: Change | Triangle: Save To File",rgb2col(50,255,50),0,0); } else { mh_print(5,255,"X: Exit | O: Increment | Square: Decrement | Triangle: Save To File",rgb2col(50,255,50),0,0); } pgScreenFlipV(); if (control_bef_ctl == 0) { Read_Key2(); pgWaitV(); } else { unsigned long ankey; while (1) { ankey = Read_Key3(); if (ankey != 0) break; pgWaitV(); } new_pad = old_pad = now_pad = ankey; control_bef_ctl = 0; } if (new_pad & SCE_CTRL_UP) { if (d_clist_curpos > 0) { d_clist_curpos--; if (d_clist_curpos < d_clist_start) { d_clist_start = d_clist_curpos; } } } else if (new_pad & SCE_CTRL_DOWN) { if (d_clist_curpos < (MAX_CONTROL-1)) { d_clist_curpos++; if (d_clist_curpos >= (d_clist_start+MAX_CONTROL-1)) { d_clist_start++; } } } else if (new_pad & SCE_CTRL_CIRCLE) { if (d_clist_curpos != 10) { ButtonChange(tempstring, buttons, tempkeystring); } else { change_cpu_clock(1); // increment } } else if (new_pad & SCE_CTRL_TRIANGLE) { SaveToFile(tempstring, buttons, tempkeystring); } else if (new_pad & SCE_CTRL_SQUARE) { if (d_clist_curpos == 10) change_cpu_clock(0); // decrement } else if (new_pad & SCE_CTRL_CROSS) { break; } } }
int Control(void) { int i; Read_Key2(); pgWaitV(); if (new_pad & PSP2_CTRL_UP) { if (dlist_curpos > 0) { dlist_curpos--; if (dlist_curpos < dlist_start) { dlist_start = dlist_curpos; } } } if (new_pad & PSP2_CTRL_DOWN) { if (dlist_curpos < (dlist_num-1)) { dlist_curpos++; if (dlist_curpos >= (dlist_start+PATHLIST_H)) { dlist_start++; } } } if (new_pad & PSP2_CTRL_LEFT) { dlist_curpos -= PATHLIST_H; if (dlist_curpos < 0) { dlist_curpos = 0; } if (dlist_curpos < dlist_start) { dlist_start = dlist_curpos; } } if (new_pad & PSP2_CTRL_RIGHT) { dlist_curpos += PATHLIST_H; if (dlist_curpos >= dlist_num) { dlist_curpos = dlist_num-1; } while (dlist_curpos >= (dlist_start+PATHLIST_H)) { dlist_start++; } } if (new_pad & PSP2_CTRL_CIRCLE) { if (dlist[dlist_curpos].type & TYPE_DIR) { if (now_depth<MAXDEPTH) { // pathÚ® strcat(doomwaddir2, dlist[dlist_curpos].name); strcat(doomwaddir2, "/"); cbuf_start[now_depth] = dlist_start; cbuf_curpos[now_depth] = dlist_curpos; dlist_start = 0; dlist_curpos = 0; now_depth++; return 1; } } else { // return 2; for(i=0;i<MAXPATH;i++) { if (dlist[dlist_curpos].name[i]==0) break; } if (i>2) { if (((dlist[dlist_curpos].name[i-3] & 0xDF) == '.') && ((dlist[dlist_curpos].name[i-2] & 0xDF) == 'G') && ((dlist[dlist_curpos].name[i-1] & 0xDF) == 'B')) { return 2; } i--; } } } if (new_pad & PSP2_CTRL_CROSS) { if (now_depth > 0) { // pathÚ® for(i=0;i<MAXPATH;i++) { if (doomwaddir2[i]==0) break; } i--; while(i>4) { if (doomwaddir2[i-1]=='/') { doomwaddir[i]=0; break; } i--; } now_depth--; dlist_start = cbuf_start[now_depth]; dlist_curpos = cbuf_curpos[now_depth]; return 1; } } return 0; }