test_app.cpp 687 B

123456789101112131415161718192021222324252627282930313233
  1. #include <stdio.h>
  2. #include "misc.h"
  3. #include "accel_cores.h"
  4. #include "graphics.h"
  5. void draw()
  6. {
  7. static uint8_t color = 0;
  8. for(int y = 0; y < FRAME_HEIGHT; ++y)
  9. {
  10. //selected accelerator
  11. accel_line(accel_line32_regs, 0, y, FRAME_WIDTH, y, color << 8);
  12. }
  13. ++color;
  14. }
  15. extern "C" void graphics_app(void)
  16. {
  17. int frame = 0;
  18. uint64_t t0 = highres_ticks();
  19. for(;;)
  20. {
  21. draw();
  22. int64_t dt = highres_ticks() - t0;
  23. printf("frame %d, t %d, FPS %d (resolution %dx%d) ticks %ld, clocks per pixel %d\n",
  24. ++frame, int(t0/highres_ticks_freq()), int(highres_ticks_freq()/dt),
  25. FRAME_WIDTH, FRAME_HEIGHT, long(dt), int(dt/(FRAME_WIDTH*FRAME_HEIGHT)));
  26. t0 = highres_ticks();
  27. }
  28. }