lcd.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. namespace LCD {
  7. struct Registers {
  8. u32 framebuffer_top_left_1;
  9. u32 framebuffer_top_left_2;
  10. u32 framebuffer_top_right_1;
  11. u32 framebuffer_top_right_2;
  12. u32 framebuffer_sub_left_1;
  13. u32 framebuffer_sub_left_2;
  14. u32 framebuffer_sub_right_1;
  15. u32 framebuffer_sub_right_2;
  16. };
  17. extern Registers g_regs;
  18. enum {
  19. TOP_ASPECT_X = 0x5,
  20. TOP_ASPECT_Y = 0x3,
  21. TOP_HEIGHT = 240,
  22. TOP_WIDTH = 400,
  23. BOTTOM_WIDTH = 320,
  24. // Physical addresses in FCRAM used by ARM9 applications - these are correct for real hardware
  25. PADDR_FRAMEBUFFER_SEL = 0x20184E59,
  26. PADDR_TOP_LEFT_FRAME1 = 0x20184E60,
  27. PADDR_TOP_LEFT_FRAME2 = 0x201CB370,
  28. PADDR_TOP_RIGHT_FRAME1 = 0x20282160,
  29. PADDR_TOP_RIGHT_FRAME2 = 0x202C8670,
  30. PADDR_SUB_FRAME1 = 0x202118E0,
  31. PADDR_SUB_FRAME2 = 0x20249CF0,
  32. // Physical addresses in VRAM - I'm not sure how these are actually allocated (so not real)
  33. PADDR_VRAM_FRAMEBUFFER_SEL = 0x18184E59,
  34. PADDR_VRAM_TOP_LEFT_FRAME1 = 0x18184E60,
  35. PADDR_VRAM_TOP_LEFT_FRAME2 = 0x181CB370,
  36. PADDR_VRAM_TOP_RIGHT_FRAME1 = 0x18282160,
  37. PADDR_VRAM_TOP_RIGHT_FRAME2 = 0x182C8670,
  38. PADDR_VRAM_SUB_FRAME1 = 0x182118E0,
  39. PADDR_VRAM_SUB_FRAME2 = 0x18249CF0,
  40. };
  41. enum {
  42. REG_FRAMEBUFFER_TOP_LEFT_1 = 0x1EF00468, // Main LCD, first framebuffer for 3D left
  43. REG_FRAMEBUFFER_TOP_LEFT_2 = 0x1EF0046C, // Main LCD, second framebuffer for 3D left
  44. REG_FRAMEBUFFER_TOP_RIGHT_1 = 0x1EF00494, // Main LCD, first framebuffer for 3D right
  45. REG_FRAMEBUFFER_TOP_RIGHT_2 = 0x1EF00498, // Main LCD, second framebuffer for 3D right
  46. REG_FRAMEBUFFER_SUB_LEFT_1 = 0x1EF00568, // Sub LCD, first framebuffer
  47. REG_FRAMEBUFFER_SUB_LEFT_2 = 0x1EF0056C, // Sub LCD, second framebuffer
  48. REG_FRAMEBUFFER_SUB_RIGHT_1 = 0x1EF00594, // Sub LCD, unused first framebuffer
  49. REG_FRAMEBUFFER_SUB_RIGHT_2 = 0x1EF00598, // Sub LCD, unused second framebuffer
  50. };
  51. /// Framebuffer location
  52. enum FramebufferLocation {
  53. FRAMEBUFFER_LOCATION_UNKNOWN, ///< Framebuffer location is unknown
  54. FRAMEBUFFER_LOCATION_FCRAM, ///< Framebuffer is in the GSP heap
  55. FRAMEBUFFER_LOCATION_VRAM, ///< Framebuffer is in VRAM
  56. };
  57. /**
  58. * Sets whether the framebuffers are in the GSP heap (FCRAM) or VRAM
  59. * @param
  60. */
  61. void SetFramebufferLocation(const FramebufferLocation mode);
  62. /**
  63. * Gets a read-only pointer to a framebuffer in memory
  64. * @param address Physical address of framebuffer
  65. * @return Returns const pointer to raw framebuffer
  66. */
  67. const u8* GetFramebufferPointer(const u32 address);
  68. /**
  69. * Gets the location of the framebuffers
  70. */
  71. const FramebufferLocation GetFramebufferLocation();
  72. template <typename T>
  73. inline void Read(T &var, const u32 addr);
  74. template <typename T>
  75. inline void Write(u32 addr, const T data);
  76. /// Update hardware
  77. void Update();
  78. /// Initialize hardware
  79. void Init();
  80. /// Shutdown hardware
  81. void Shutdown();
  82. } // namespace