logo.ino 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include <EEPROM.h>
  2. #include <SPI.h>
  3. #include <GD2.h>
  4. #include "logo_assets.h"
  5. void setup()
  6. {
  7. Serial.begin(1000000); // JCB
  8. GD.begin();
  9. LOAD_ASSETS();
  10. }
  11. byte clamp255(int x)
  12. {
  13. if (x < 0)
  14. return 0;
  15. if (255 < x)
  16. return 255;
  17. return x;
  18. }
  19. struct xy {
  20. int x, y;
  21. };
  22. #define NSTARS 256
  23. void loop()
  24. {
  25. byte fade;
  26. xy stars[NSTARS];
  27. for (int i = 0; i < NSTARS; i++) {
  28. stars[i].x = GD.random(16 * 480);
  29. stars[i].y = GD.random(16 * 272);
  30. }
  31. for (int t = 0; t < 464; t++) {
  32. GD.cmd_gradient(0, 0, 0x120000, 0, 272, 0x480000);
  33. GD.BlendFunc(SRC_ALPHA, ONE);
  34. GD.Begin(POINTS);
  35. for (int i = 0; i < NSTARS; i++) {
  36. GD.ColorA(64 + (i >> 2));
  37. GD.PointSize(8 + (i >> 5));
  38. GD.Vertex2f(stars[i].x, stars[i].y);
  39. // stars drift left, then wrap around
  40. stars[i].x -= 1 + (i >> 5);
  41. if (stars[i].x < -256) {
  42. stars[i].x += (16 * 500);
  43. stars[i].y = GD.random(16 * 272);
  44. }
  45. }
  46. GD.RestoreContext();
  47. GD.Begin(BITMAPS);
  48. // Main logo fades up from black
  49. fade = clamp255(5 * (t - 15));
  50. GD.ColorRGB(fade, fade, fade);
  51. GD.Vertex2ii(240 - GAMEDUINO_WIDTH/2, 65, GAMEDUINO_HANDLE, 0);
  52. GD.RestoreContext();
  53. // The '2' and its glow
  54. fade = clamp255(8 * (t - 120));
  55. GD.ColorA(fade);
  56. GD.Vertex2ii(270, 115, TWO_HANDLE, 0);
  57. fade = clamp255(5 * (t - 144));
  58. GD.BlendFunc(SRC_ALPHA, ONE);
  59. GD.ColorA(fade);
  60. GD.ColorRGB(85,85,85);
  61. GD.Vertex2ii(270, 115, TWO_HANDLE, 1);
  62. GD.RestoreContext();
  63. // The text fades up. Its glow is a full-screen bitmap
  64. fade = clamp255(8 * (t - 160));
  65. GD.ColorA(fade);
  66. GD.cmd_text(140, 200, 29, OPT_CENTER, "This time");
  67. GD.cmd_text(140, 225, 29, OPT_CENTER, "it's personal");
  68. fade = clamp255(5 * (t - 184));
  69. GD.BlendFunc(SRC_ALPHA, ONE);
  70. GD.ColorA(fade);
  71. GD.ColorRGB(85,85,85);
  72. GD.Vertex2ii(0, 0, PERSONAL_HANDLE, 0);
  73. // OSHW logo fades in
  74. GD.ColorRGB(0, 153 * 160 / 255, 176 * 160 / 255);
  75. GD.Vertex2ii(2, 2, OSHW_HANDLE, 0);
  76. GD.RestoreContext();
  77. // Fade to white at the end by drawing a white rectangle on top
  78. fade = clamp255(5 * (t - 400));
  79. GD.ColorA(fade);
  80. GD.Begin(RECTS);
  81. GD.Vertex2ii(0, 0, 0, 0);
  82. GD.Vertex2ii(480, 272, 0, 0);
  83. GD.swap();
  84. }
  85. }