/****************************************************** * DISPLAY SCORE * DESCRIPTION: Shows the player scores on the screen. ******************************************************/ void displayPongScore(unsigned int* inUserScore, unsigned int* inCompScore) //Pass by ref { set_LCD_Cursor(0, 0); printf_string(" "); set_LCD_Cursor(25, 0); printf_int(*inUserScore); set_LCD_Cursor(45, 0); printf_int(*inCompScore); }
/*********************************************************** * SHOW JET SCORE * DESCRIPTION: Shows the current stats of the game. ***********************************************************/ void showPongScore(unsigned int player, unsigned int computer, unsigned int highScore) { LcdClear(); printf_5Words("Plyr: ", "Cmp: ", "High: ", "", "", 10); set_LCD_Cursor(30, 0); printf_int(player); set_LCD_Cursor(30, 1); printf_int(computer); set_LCD_Cursor(30, 2); printf_int(highScore); WaitUserInput(); }
/*********************************************************** * SHOW JET SCORE * DESCRIPTION: Shows the current stats of the game. ***********************************************************/ void showJetScore(unsigned int ballsDestroyed, unsigned int health, unsigned int highScore) { LcdClear(); printf_5Words("Hit: ", "Hlth: ", "High: ", "", "", 10); set_LCD_Cursor(30, 0); printf_int(ballsDestroyed); set_LCD_Cursor(30, 1); printf_int(health); set_LCD_Cursor(30, 2); printf_int(highScore); StartTimer(0, 200); WaitUserInput(); }
char *printf_d(char *f, char type, intmax_t ld) { int d; int hjz; d = ld; hjz = ft_is_hjz(f); if (type == 'D' || type == 'I') return (printf_lint(f, (long int)ld)); if (type == 'd' || type == 'i' || type == 'c') { if (hjz == 1 && type != 'c') return (printf_int(f, type, (short int)d)); else if (hjz == 3 && type != 'c') return (printf_int(f, type, ld)); else if (hjz == 4 && type != 'c') return (printf_int(f, type, (size_t)ld)); else if (hjz == 2 && type != 'c') return (printf_int(f, type, (signed char)d)); else if (hjz == 5 && type != 'c') return (printf_int(f, type, (long long int)ld)); else return (printf_int(f, type, d)); } if (type == 'p') return (printf_hexa(f, 'p', ld)); return (f); }
void printk(const char* format, ...) { void* cur_address = (char*)&format + sizeof(char**); int i = 0; while(format[i] != '\0') { if(format[i] == '%') { i++; switch(format[i]) { case 'd' : { int val = *((int*) cur_address); cur_address = (char*)cur_address + sizeof(int); printf_int(val); break; } case 'x' : { unsigned int val = *((unsigned int*) cur_address); cur_address = (char*)cur_address + sizeof(int); printf_int_x(val); break; } case 'c' : { char val = *((char*) cur_address); cur_address = (char*)cur_address + sizeof(int); serial_printc(val); break; } case 's' : { char* str = (char*)(*((char**)cur_address)); while(*str != '\0') { serial_printc(*str); str++; } cur_address = (char*)cur_address + sizeof(char**); break; } case '%' : serial_printc('%'); break; } } else { serial_printc(format[i]); } i++; } }
int main() { WDTCTL = WDTPW | WDTHOLD; uart_init(); printf_int("\n---------------\n[main] started, I have id %d\n\n", sancus_get_self_id()); sancus_enable(&a); sancus_enable(&foo); sancus_enable(&bar); sancus_enable(&scheduler); //do_control_flow_integrity_hack(); puts("[main] set sm internal vars"); set_a_vars(); set_bar_vars(); set_foo_vars(); puts("[main] initializing scheduler"); initialize_scheduler(); register_thread_portal(&a, SM_GET_ENTRY_IDX(a, enter_a)); register_thread_portal(&foo, SM_GET_ENTRY_IDX(foo, enter_foo)); register_thread_portal(&bar, SM_GET_ENTRY_IDX(bar, call_a_illegal_ret)); dump_scheduler(); puts("[main] dumping thr ids"); print_a_cur_thr_id(); print_bar_cur_thr_id(); print_foo_cur_thr_id(); puts("[main] starting scheduler"); start_scheduling(); puts("[main] return from scheduler:"); dump_scheduler(); puts("[main] dumping thr ids"); print_a_cur_thr_id(); print_bar_cur_thr_id(); print_foo_cur_thr_id(); puts("\n[main] exiting\n-----------------"); EXIT }