tc6393xb_template.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Toshiba TC6393XB I/O Controller.
  3. * Found in Sharp Zaurus SL-6000 (tosa) or some
  4. * Toshiba e-Series PDAs.
  5. *
  6. * FB support code. Based on G364 fb emulator
  7. *
  8. * Copyright (c) 2007 Hervé Poussineau
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, see <http://www.gnu.org/licenses/>.
  22. */
  23. #if BITS == 8
  24. # define SET_PIXEL(addr, color) (*(uint8_t *)addr = color)
  25. #elif BITS == 15 || BITS == 16
  26. # define SET_PIXEL(addr, color) (*(uint16_t *)addr = color)
  27. #elif BITS == 24
  28. # define SET_PIXEL(addr, color) \
  29. do { \
  30. addr[0] = color; \
  31. addr[1] = (color) >> 8; \
  32. addr[2] = (color) >> 16; \
  33. } while (0)
  34. #elif BITS == 32
  35. # define SET_PIXEL(addr, color) (*(uint32_t *)addr = color)
  36. #else
  37. # error unknown bit depth
  38. #endif
  39. static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s)
  40. {
  41. DisplaySurface *surface = qemu_console_surface(s->con);
  42. int i;
  43. uint16_t *data_buffer;
  44. uint8_t *data_display;
  45. data_buffer = s->vram_ptr;
  46. data_display = surface_data(surface);
  47. for(i = 0; i < s->scr_height; i++) {
  48. #if (BITS == 16)
  49. memcpy(data_display, data_buffer, s->scr_width * 2);
  50. data_buffer += s->scr_width;
  51. data_display += surface_stride(surface);
  52. #else
  53. int j;
  54. for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
  55. uint16_t color = *data_buffer;
  56. uint32_t dest_color = glue(rgb_to_pixel, BITS)(
  57. ((color & 0xf800) * 0x108) >> 11,
  58. ((color & 0x7e0) * 0x41) >> 9,
  59. ((color & 0x1f) * 0x21) >> 2
  60. );
  61. SET_PIXEL(data_display, dest_color);
  62. }
  63. #endif
  64. }
  65. }
  66. #undef BITS
  67. #undef SET_PIXEL