rectangle_fill32.cc 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //(C) 2023 Victor Suarez Rovere <suarezvictor@gmail.com>
  2. // SPDX-License-Identifier: AGPL-3.0-only
  3. #include "cflexhdl.h"
  4. #include "bus.h"
  5. #include "graphics.h"
  6. MODULE rectangle_fill32(
  7. bus_master(bus),
  8. const uint16& x0,
  9. const uint16& x1,
  10. const uint16& y0,
  11. const uint16& y1,
  12. const uint32& rgba, //color
  13. const busaddr_t& base, //pixel offset
  14. const int16& xstride, //normally 4, but can run backwards
  15. const int16& ystride //bytes to skip for next line (usually the framebuffer width * 4 bytes)
  16. )
  17. {
  18. busaddr_t yaddr;
  19. uint16 x, y;
  20. bus_setup32();
  21. yaddr = base;
  22. for(y = y0; y < y1; y = y + 1)
  23. {
  24. bus_set_address(yaddr);
  25. for(x = x0; x < x1; )
  26. {
  27. bus_write_start(rgba);
  28. if(!bus_write_pending())
  29. {
  30. bus_stop();
  31. bus_inc_address(xstride);
  32. x = x + 1;
  33. }
  34. }
  35. while(bus_write_pending());
  36. bus_release();
  37. yaddr = yaddr + ystride;
  38. }
  39. }