spc7110.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*****
  2. * SPC7110 emulator - version 0.03 (2008-08-10)
  3. * Copyright (c) 2008, byuu and neviksti
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * The software is provided "as is" and the author disclaims all warranties
  10. * with regard to this software including all implied warranties of
  11. * merchantibility and fitness, in no event shall the author be liable for
  12. * any special, direct, indirect, or consequential damages or any damages
  13. * whatsoever resulting from loss of use, data or profits, whether in an
  14. * action of contract, negligence or other tortious action, arising out of
  15. * or in connection with the use or performance of this software.
  16. *****/
  17. #include "decomp.hpp"
  18. class SPC7110 : public MMIO, public Memory {
  19. public:
  20. void init();
  21. void enable();
  22. void power();
  23. void reset();
  24. unsigned datarom_addr(unsigned addr);
  25. unsigned data_pointer();
  26. unsigned data_adjust();
  27. unsigned data_increment();
  28. void set_data_pointer(unsigned addr);
  29. void set_data_adjust(unsigned addr);
  30. void update_time(int offset = 0);
  31. time_t create_time();
  32. uint8 mmio_read (unsigned addr);
  33. void mmio_write(unsigned addr, uint8 data);
  34. uint8 read (unsigned addr);
  35. void write(unsigned addr, uint8 data);
  36. //spc7110decomp
  37. void decomp_init();
  38. uint8 decomp_read();
  39. SPC7110();
  40. private:
  41. //==================
  42. //decompression unit
  43. //==================
  44. uint8 r4801; //compression table low
  45. uint8 r4802; //compression table high
  46. uint8 r4803; //compression table bank
  47. uint8 r4804; //compression table index
  48. uint8 r4805; //decompression buffer index low
  49. uint8 r4806; //decompression buffer index high
  50. uint8 r4807; //???
  51. uint8 r4808; //???
  52. uint8 r4809; //compression length low
  53. uint8 r480a; //compression length high
  54. uint8 r480b; //decompression control register
  55. uint8 r480c; //decompression status
  56. SPC7110Decomp decomp;
  57. //==============
  58. //data port unit
  59. //==============
  60. uint8 r4811; //data pointer low
  61. uint8 r4812; //data pointer high
  62. uint8 r4813; //data pointer bank
  63. uint8 r4814; //data adjust low
  64. uint8 r4815; //data adjust high
  65. uint8 r4816; //data increment low
  66. uint8 r4817; //data increment high
  67. uint8 r4818; //data port control register
  68. uint8 r481x;
  69. bool r4814_latch;
  70. bool r4815_latch;
  71. //=========
  72. //math unit
  73. //=========
  74. uint8 r4820; //16-bit multiplicand B0, 32-bit dividend B0
  75. uint8 r4821; //16-bit multiplicand B1, 32-bit dividend B1
  76. uint8 r4822; //32-bit dividend B2
  77. uint8 r4823; //32-bit dividend B3
  78. uint8 r4824; //16-bit multiplier B0
  79. uint8 r4825; //16-bit multiplier B1
  80. uint8 r4826; //16-bit divisor B0
  81. uint8 r4827; //16-bit divisor B1
  82. uint8 r4828; //32-bit product B0, 32-bit quotient B0
  83. uint8 r4829; //32-bit product B1, 32-bit quotient B1
  84. uint8 r482a; //32-bit product B2, 32-bit quotient B2
  85. uint8 r482b; //32-bit product B3, 32-bit quotient B3
  86. uint8 r482c; //16-bit remainder B0
  87. uint8 r482d; //16-bit remainder B1
  88. uint8 r482e; //math control register
  89. uint8 r482f; //math status
  90. //===================
  91. //memory mapping unit
  92. //===================
  93. uint8 r4830; //SRAM write enable
  94. uint8 r4831; //$[d0-df]:[0000-ffff] mapping
  95. uint8 r4832; //$[e0-ef]:[0000-ffff] mapping
  96. uint8 r4833; //$[f0-ff]:[0000-ffff] mapping
  97. uint8 r4834; //???
  98. unsigned dx_offset;
  99. unsigned ex_offset;
  100. unsigned fx_offset;
  101. //====================
  102. //real-time clock unit
  103. //====================
  104. uint8 r4840; //RTC latch
  105. uint8 r4841; //RTC index/data port
  106. uint8 r4842; //RTC status
  107. enum RTC_State { RTCS_Inactive, RTCS_ModeSelect, RTCS_IndexSelect, RTCS_Write } rtc_state;
  108. enum RTC_Mode { RTCM_Linear = 0x03, RTCM_Indexed = 0x0c } rtc_mode;
  109. unsigned rtc_index;
  110. static const unsigned months[12];
  111. };
  112. extern SPC7110 spc7110;