atm959

Simple Time Keeper GBA C Code

Jul 4th, 2016
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <gba_console.h>
  2. #include <gba_video.h>
  3. #include <gba_interrupt.h>
  4. #include <gba_systemcalls.h>
  5. #include <gba_input.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. int frames = 0;
  10. int seconds = 0;
  11. int minutes = 0;
  12.  
  13. //---------------------------------------------------------------------------------
  14. // Program entry point
  15. //---------------------------------------------------------------------------------
  16. int main(void) {
  17. //---------------------------------------------------------------------------------
  18.  
  19.  
  20. // the vblank interrupt must be enabled for VBlankIntrWait() to work
  21. // since the default dispatcher handles the bios flags no vblank handler
  22. // is required
  23. irqInit();
  24. irqEnable(IRQ_VBLANK);
  25.  
  26. consoleDemoInit();
  27.  
  28. // ansi escape sequence to set print co-ordinates
  29. // /x1b[line;columnH
  30.  
  31. printf("SIMPLE TIME KEEPER\n");
  32. printf("BY atm959\n");
  33.  
  34. while (1) {
  35.  
  36. if(frames < 60){
  37.  
  38. frames++;
  39.  
  40. } else if(frames == 60){
  41.  
  42. if(seconds < 60){
  43.  
  44. seconds++;
  45.  
  46. } else if(seconds == 60){
  47.  
  48. minutes++;
  49. printf("\x1b[4;0HSeconds: ");
  50. seconds = 0;
  51.  
  52. }
  53. printf("\x1b[3;0HFrames: ");
  54. frames = 0;
  55.  
  56. }
  57.  
  58. printf("\x1b[3;0HFrames: %d", frames);
  59. printf("\x1b[4;0HSeconds: %d", seconds);
  60. printf("\x1b[5;0HMinutes: %d", minutes);
  61.  
  62. printf("\x1b[7;0HThis was programmed in C\nin Programmer\'s Notepad\nwith devkitPro.");
  63.  
  64. VBlankIntrWait();
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment