GoudaSCSI.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "GoudaSCSI.hh"
  2. #include "serialize.hh"
  3. #include "unreachable.hh"
  4. namespace openmsx {
  5. GoudaSCSI::GoudaSCSI(const DeviceConfig& config)
  6. : MSXDevice(config)
  7. , rom(getName() + " ROM", "rom", config)
  8. , wd33c93(config)
  9. {
  10. reset(EmuTime::dummy());
  11. }
  12. void GoudaSCSI::reset(EmuTime::param /*time*/)
  13. {
  14. wd33c93.reset(true);
  15. }
  16. byte GoudaSCSI::readIO(word port, EmuTime::param /*time*/)
  17. {
  18. switch (port & 0x03) {
  19. case 0:
  20. return wd33c93.readAuxStatus();
  21. case 1:
  22. return wd33c93.readCtrl();
  23. case 2:
  24. return 0xb0; // bit 4: 1 = Halt on SCSI parity error
  25. default:
  26. UNREACHABLE; return 0;
  27. }
  28. }
  29. byte GoudaSCSI::peekIO(word port, EmuTime::param /*time*/) const
  30. {
  31. switch (port & 0x03) {
  32. case 0:
  33. return wd33c93.peekAuxStatus();
  34. case 1:
  35. return wd33c93.peekCtrl();
  36. case 2:
  37. return 0xb0; // bit 4: 1 = Halt on SCSI parity error
  38. default:
  39. UNREACHABLE; return 0;
  40. }
  41. }
  42. void GoudaSCSI::writeIO(word port, byte value, EmuTime::param time)
  43. {
  44. switch (port & 0x03) {
  45. case 0:
  46. wd33c93.writeAdr(value);
  47. break;
  48. case 1:
  49. wd33c93.writeCtrl(value);
  50. break;
  51. case 2:
  52. reset(time);
  53. break;
  54. default:
  55. UNREACHABLE;
  56. }
  57. }
  58. byte GoudaSCSI::readMem(word address, EmuTime::param /*time*/)
  59. {
  60. return *GoudaSCSI::getReadCacheLine(address);
  61. }
  62. const byte* GoudaSCSI::getReadCacheLine(word start) const
  63. {
  64. return &rom[start & (rom.getSize() - 1)];
  65. }
  66. template<typename Archive>
  67. void GoudaSCSI::serialize(Archive& ar, unsigned /*version*/)
  68. {
  69. ar.template serializeBase<MSXDevice>(*this);
  70. ar.serialize("WD33C93", wd33c93);
  71. }
  72. INSTANTIATE_SERIALIZE_METHODS(GoudaSCSI);
  73. REGISTER_MSXDEVICE(GoudaSCSI, "GoudaSCSI");
  74. } // namespace openmsx