splitscreen.ino 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. Serial.begin(1000000); // JCB
  21. GD.copy(RAM_PIC, splitscreen_pic, sizeof(splitscreen_pic));
  22. GD.copy(RAM_CHR, splitscreen_chr, sizeof(splitscreen_chr));
  23. GD.copy(RAM_PAL, splitscreen_pal, sizeof(splitscreen_pal));
  24. GD.wr16(COMM+0, 0);
  25. GD.wr16(COMM+2, 0);
  26. GD.wr16(COMM+4, 100); // split at line 100
  27. GD.wr16(COMM+6, 0);
  28. GD.wr16(COMM+8, 140);
  29. GD.wr16(COMM+10, 200); // split at line 200
  30. GD.wr16(COMM+12, 0);
  31. GD.wr16(COMM+14, (511 & (82 - 200))); // show line 82 at line 200
  32. GD.microcode(splitscreen_code, sizeof(splitscreen_code));
  33. }
  34. // Set the scroll registers for the middle screen secion to (x, y)
  35. static void scrollxy(uint16_t x, uint16_t y)
  36. {
  37. GD.wr16(COMM+6, x);
  38. GD.wr16(COMM+8, y);
  39. }
  40. void loop()
  41. {
  42. static int i;
  43. float th = i / 16.;
  44. scrollxy(55 + 50 * cos(th), 150 + 50 * sin(th));
  45. GD.wr16(COMM+12, i);
  46. i++;
  47. GD.waitvblank();
  48. // GD.screenshot(i); // JCB
  49. }