SHARE
TWEET

Untitled

a guest Aug 14th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  *--------------------------------------
  3.  * Program Name: CUBE
  4.  * Author: De2290 aka kafirhamsaeiyya
  5.  * License: GNU GPLv3
  6.  * Description: A simple cube timer for the TI84 Plus CE
  7.  *--------------------------------------
  8. */
  9.  
  10. /* Keep these headers */
  11. #include <stdbool.h>
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <tice.h>
  15.  
  16. /* Standard headers (recommended) */
  17. #include <math.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <graphx.h>
  22. #include "gfx/logo_gfx.h"
  23. #define FONT_HEIGHT 8
  24. /* Put your function prototypes here */
  25. void dispSprite_Centered(gfx_sprite_t *sprite);
  26. void print_Time(float elasped);
  27. void print_TextCentered(char *text);
  28. /* Put all your globals here */
  29.  
  30. void main(void) {
  31.     char *cubewelcome = "Cube Timer";
  32.     real_t cubeFinish_time;
  33.     list_t *times_List;
  34.     gfx_Begin();
  35.     gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
  36.     gfx_SetTextFGColor(255);
  37.     gfx_FillScreen(0);
  38.     gfx_SetTextTransparentColor(1);
  39.     gfx_SetTextBGColor(0);
  40.     print_TextCentered(cubewelcome);
  41.     dispSprite_Centered(rubikcube);
  42.     print_Time(0.0f);
  43.     timer_Control = TIMER1_DISABLE;
  44.     timer_1_Counter = 0;
  45.     while (!os_GetCSC());
  46.     timer_Control = TIMER1_ENABLE | TIMER1_32K | TIMER1_UP;
  47.     do {
  48.         float elapsed = (float)atomic_load_increasing_32(&timer_1_Counter) / 32768;
  49.         print_Time(elapsed);
  50.             cubeFinish_time = os_FloatToReal(elapsed);
  51.  
  52.     } while (!os_GetCSC());
  53.     times_List = ti_MallocList(1);
  54.     times_List->items[0] = cubeFinish_time;
  55.     ti_SetVar(TI_REAL_LIST_TYPE, ti_L1, times_List);
  56.     free(times_List);
  57.     while (!os_GetCSC());
  58.  
  59.  
  60.    
  61.     gfx_End();
  62.  
  63. }
  64.  
  65. /* Put other functions here */
  66. void dispSprite_Centered(gfx_sprite_t *sprite) {
  67.     gfx_Sprite(sprite, (LCD_WIDTH - 60) / 2, (LCD_HEIGHT - 60) / 2);
  68. }
  69.  
  70. void print_Time(float elapsed) {
  71.     real_t elapsed_real;
  72.     char str[10];
  73.     elapsed_real = os_FloatToReal(elapsed <= 0.001f ? 0.0f : elapsed);
  74.     os_RealToStr(str, &elapsed_real, 8, 1, 2);
  75.     gfx_PrintStringXY(str, (LCD_WIDTH - gfx_GetStringWidth(str)) / 2, (LCD_HEIGHT - FONT_HEIGHT) / 2+60);
  76.  
  77. }
  78.  
  79. void print_TextCentered(char *text) {
  80.     gfx_PrintStringXY(text, (LCD_WIDTH - gfx_GetStringWidth(text)) / 2, (LCD_HEIGHT - FONT_HEIGHT) / 2-60);
  81. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top