splitscreen.pde 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <SPI.h>
  2. #include <GD.h>
  3. #include "splitscreen.h"
  4. /*
  5. For the splitscreen microprogram, the COMM area holds 8 short words
  6. that control the 3-way screen split:
  7. COMM+0 SCROLL_X for top section
  8. COMM+2 SCROLL_Y for top section
  9. COMM+4 Y-coordinate of start of middle section
  10. COMM+6 SCROLL_X for middle section
  11. COMM+8 SCROLL_Y for middle section
  12. COMM+10 Y-coordinate of start of bottom section
  13. COMM+12 SCROLL_X for bottom section
  14. COMM+14 SCROLL_Y for bottom section
  15. */
  16. #include "splitscreen_graphics.h"
  17. void setup()
  18. {
  19. GD.begin();
  20. GD.copy(RAM_PIC, splitscreen_pic, sizeof(splitscreen_pic));
  21. GD.copy(RAM_CHR, splitscreen_chr, sizeof(splitscreen_chr));
  22. GD.copy(RAM_PAL, splitscreen_pal, sizeof(splitscreen_pal));
  23. GD.wr16(COMM+0, 0);
  24. GD.wr16(COMM+2, 0);
  25. GD.wr16(COMM+4, 100); // split at line 100
  26. GD.wr16(COMM+6, 0);
  27. GD.wr16(COMM+8, 140);
  28. GD.wr16(COMM+10, 200); // split at line 200
  29. GD.wr16(COMM+12, 0);
  30. GD.wr16(COMM+14, (511 & (82 - 200))); // show line 82 at line 200
  31. GD.microcode(splitscreen_code, sizeof(splitscreen_code));
  32. }
  33. // Set the scroll registers for the middle screen secion to (x, y)
  34. static void scrollxy(uint16_t x, uint16_t y)
  35. {
  36. GD.wr16(COMM+6, x);
  37. GD.wr16(COMM+8, y);
  38. }
  39. void loop()
  40. {
  41. static int i;
  42. float th = i / 16.;
  43. scrollxy(55 + 50 * cos(th), 150 + 50 * sin(th));
  44. GD.wr16(COMM+12, i);
  45. i++;
  46. GD.waitvblank();
  47. }