1
0

PXTEST.C 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #define word char
  2. #include "LIB/MATH.C"
  3. #include "LIB/STDLIB.C"
  4. #include "LIB/SYS.C"
  5. #define SCREEN_WIDTH 320
  6. #define SCREEN_HEIGHT 240
  7. #define FB_ADDR 0xD00000
  8. // Framebuffer. fb[Y][X] (bottom right is [239][319])
  9. char (*fb)[SCREEN_WIDTH] = (char (*)[SCREEN_WIDTH]) FB_ADDR;
  10. int main()
  11. {
  12. word pxcount = 0;
  13. word x, y;
  14. while (1)
  15. {
  16. if (HID_FifoAvailable())
  17. {
  18. word c = HID_FifoRead();
  19. if (c == 'a')
  20. {
  21. for (x = 0; x < SCREEN_WIDTH; x++)
  22. {
  23. for (y = 0; y < SCREEN_HEIGHT; y++)
  24. {
  25. fb[y][x] = 0;
  26. }
  27. }
  28. }
  29. if (c == 'b')
  30. {
  31. for (x = 0; x < SCREEN_WIDTH; x++)
  32. {
  33. for (y = 0; y < SCREEN_HEIGHT; y++)
  34. {
  35. fb[y][x] = x;
  36. }
  37. }
  38. }
  39. if (c == 'c')
  40. {
  41. for (x = 0; x < SCREEN_WIDTH; x++)
  42. {
  43. for (y = 0; y < SCREEN_HEIGHT; y++)
  44. {
  45. fb[y][x] = y;
  46. }
  47. }
  48. }
  49. if (c == 'd')
  50. {
  51. pxcount = 0;
  52. for (x = 0; x < SCREEN_WIDTH; x++)
  53. {
  54. for (y = 0; y < SCREEN_HEIGHT; y++)
  55. {
  56. fb[y][x] = pxcount;
  57. pxcount++;
  58. }
  59. }
  60. }
  61. if (c == 27) // escape
  62. {
  63. for (x = 0; x < SCREEN_WIDTH; x++)
  64. {
  65. for (y = 0; y < SCREEN_HEIGHT; y++)
  66. {
  67. fb[y][x] = 0;
  68. }
  69. }
  70. return 'q';
  71. }
  72. }
  73. }
  74. return 'q';
  75. }
  76. void interrupt()
  77. {
  78. // handle all interrupts
  79. word i = getIntID();
  80. switch(i)
  81. {
  82. case INTID_TIMER1:
  83. timer1Value = 1; // notify ending of timer1
  84. break;
  85. case INTID_TIMER2:
  86. break;
  87. case INTID_UART0:
  88. break;
  89. case INTID_GPU:
  90. break;
  91. case INTID_TIMER3:
  92. break;
  93. case INTID_PS2:
  94. break;
  95. case INTID_UART1:
  96. break;
  97. case INTID_UART2:
  98. break;
  99. }
  100. }