MSXBunsetsu.cc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "MSXBunsetsu.hh"
  2. #include "CacheLine.hh"
  3. #include "serialize.hh"
  4. namespace openmsx {
  5. MSXBunsetsu::MSXBunsetsu(const DeviceConfig& config)
  6. : MSXDevice(config)
  7. , bunsetsuRom(getName() + "_1", "rom", config, "bunsetsu")
  8. , jisyoRom (getName() + "_2", "rom", config, "jisyo")
  9. {
  10. reset(EmuTime::dummy());
  11. }
  12. void MSXBunsetsu::reset(EmuTime::param /*time*/)
  13. {
  14. jisyoAddress = 0;
  15. }
  16. byte MSXBunsetsu::readMem(word address, EmuTime::param /*time*/)
  17. {
  18. byte result;
  19. if (address == 0xBFFF) {
  20. result = jisyoRom[jisyoAddress];
  21. jisyoAddress = (jisyoAddress + 1) & 0x1FFFF;
  22. } else if ((0x4000 <= address) && (address < 0xC000)) {
  23. result = bunsetsuRom[address - 0x4000];
  24. } else {
  25. result = 0xFF;
  26. }
  27. return result;
  28. }
  29. void MSXBunsetsu::writeMem(word address, byte value, EmuTime::param /*time*/)
  30. {
  31. switch (address) {
  32. case 0xBFFC:
  33. jisyoAddress = (jisyoAddress & 0x1FF00) | value;
  34. break;
  35. case 0xBFFD:
  36. jisyoAddress = (jisyoAddress & 0x100FF) | (value << 8);
  37. break;
  38. case 0xBFFE:
  39. jisyoAddress = (jisyoAddress & 0x0FFFF) |
  40. ((value & 1) << 16);
  41. break;
  42. }
  43. }
  44. const byte* MSXBunsetsu::getReadCacheLine(word start) const
  45. {
  46. if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) {
  47. return nullptr;
  48. } else {
  49. return &bunsetsuRom[start - 0x4000];
  50. }
  51. }
  52. byte* MSXBunsetsu::getWriteCacheLine(word start) const
  53. {
  54. if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) {
  55. return nullptr;
  56. } else {
  57. return unmappedWrite;
  58. }
  59. }
  60. template<typename Archive>
  61. void MSXBunsetsu::serialize(Archive& ar, unsigned /*version*/)
  62. {
  63. ar.template serializeBase<MSXDevice>(*this);
  64. ar.serialize("jisyoAddress", jisyoAddress);
  65. }
  66. INSTANTIATE_SERIALIZE_METHODS(MSXBunsetsu);
  67. REGISTER_MSXDEVICE(MSXBunsetsu, "Bunsetsu");
  68. } // namespace openmsx