openMSX
VDP.hh
Go to the documentation of this file.
1 #ifndef VDP_HH
2 #define VDP_HH
3 
4 #include "MSXDevice.hh"
5 #include "Schedulable.hh"
7 #include "SimpleDebuggable.hh"
8 #include "TclCallback.hh"
9 #include "InfoTopic.hh"
10 #include "IRQHelper.hh"
11 #include "Clock.hh"
12 #include "DisplayMode.hh"
13 #include "Observer.hh"
14 #include "openmsx.hh"
15 #include "outer.hh"
16 #include <memory>
17 #include <array>
18 
19 namespace openmsx {
20 
21 class PostProcessor;
22 class Renderer;
23 class VDPCmdEngine;
24 class VDPVRAM;
25 class MSXCPU;
26 class SpriteChecker;
27 class Display;
28 class RawFrame;
29 class Setting;
30 template<typename> class EnumSetting;
31 namespace VDPAccessSlots {
32  enum Delta : int;
33  class Calculator;
34 }
35 
61 class VDP final : public MSXDevice, private VideoSystemChangeListener
62  , private Observer<Setting>
63 {
64 public:
67  static constexpr int TICKS_PER_SECOND = 3579545 * 6; // 21.5MHz;
69 
72  static constexpr int TICKS_PER_LINE = 1368;
73 
74  explicit VDP(const DeviceConfig& config);
75  ~VDP() override;
76 
77  void powerUp(EmuTime::param time) override;
78  void reset(EmuTime::param time) override;
79  byte readIO(word port, EmuTime::param time) override;
80  byte peekIO(word port, EmuTime::param time) const override;
81  void writeIO(word port, byte value, EmuTime::param time) override;
82 
88 
93  inline bool isMSX1VDP() const {
94  return (version & VM_MSX1) != 0;
95  }
96 
100  inline bool isVDPwithPALonly() const {
101  return (version & VM_PAL) != 0;
102  }
103 
107  inline bool vdpLacksMirroring() const {
108  return (version & VM_NO_MIRRORING) != 0;
109  }
110 
114  inline bool vdpHasPatColMirroring() const {
115  return (version & VM_PALCOL_MIRRORING) != 0;
116  }
117 
121  inline bool isVDPwithVRAMremapping() const {
122  return (version & VM_VRAM_REMAPPING) != 0;
123  }
124 
128  inline bool hasYJK() const {
129  return (version & VM_YJK) != 0;
130  }
131 
136  std::array<std::array<uint8_t, 3>, 16> getMSX1Palette() const;
137 
141  inline DisplayMode getDisplayMode() const {
142  return displayMode;
143  }
144 
147  inline VDPVRAM& getVRAM() {
148  return *vram;
149  }
150 
155  inline const RawFrame* isSuperimposing() const {
156  // Note that bit 0 of r#0 has no effect on an V9938 or higher,
157  // but this bit is masked out. Also note that on an MSX1, if
158  // bit 0 of r#0 is enabled and there is no external video
159  // source, then we lose sync.
160  // Also note that because this property is fixed per frame we
161  // cannot (re)calculate it from register values.
162  return superimposing;
163  }
164 
168  return *spriteChecker;
169  }
170 
174  inline bool getTransparency() const {
175  return (controlRegs[8] & 0x20) == 0;
176  }
177 
180  bool canSpriteColor0Collide() const {
181  // On MSX1 (so far only tested a TMS9129(?)) sprites with
182  // color=0 can always collide with other sprites. Though on
183  // V99x8 (only tested V9958) collisions only occur when color 0
184  // is not transparent. For more details see:
185  // https://github.com/openMSX/openMSX/issues/1198
186  return isMSX1VDP() || !getTransparency();
187  }
188 
192  inline int getForegroundColor() const {
193  return controlRegs[7] >> 4;
194  }
195 
204  inline int getBackgroundColor() const {
205  byte reg7 = controlRegs[7];
206  if (displayMode.getByte() == DisplayMode::GRAPHIC7) {
207  return reg7;
208  } else {
209  return reg7 & 0x0F;
210  }
211  }
212 
216  inline int getBlinkForegroundColor() const {
217  return controlRegs[12] >> 4;
218  }
219 
223  inline int getBlinkBackgroundColor() const {
224  return controlRegs[12] & 0x0F;
225  }
226 
230  inline bool getBlinkState() const {
231  return blinkState;
232  }
233 
239  inline word getPalette(int index) const {
240  return palette[index];
241  }
242 
248  inline bool isDisplayEnabled() const {
249  return isDisplayArea && displayEnabled;
250  }
251 
256  inline bool spritesEnabled() const {
257  return displayEnabled &&
258  (displayMode.getSpriteMode(isMSX1VDP()) != 0) &&
259  ((controlRegs[8] & 0x02) == 0x00);
260  }
261 
265  inline bool spritesEnabledFast() const {
266  assert(displayMode.getSpriteMode(isMSX1VDP()) != 0);
267  return displayEnabled && ((controlRegs[8] & 0x02) == 0x00);
268  }
269 
273  inline bool spritesEnabledRegister() const {
274  return (controlRegs[8] & 0x02) == 0x00;
275  }
276 
280  inline byte getVerticalScroll() const {
281  return controlRegs[23];
282  }
283 
289  inline byte getHorizontalScrollLow() const {
290  return controlRegs[27];
291  }
292 
298  inline byte getHorizontalScrollHigh() const {
299  return controlRegs[26];
300  }
301 
307  inline bool isBorderMasked() const {
308  return (controlRegs[25] & 0x02) != 0;
309  }
310 
317  inline bool isMultiPageScrolling() const {
318  return (controlRegs[25] & 0x01) && (controlRegs[2] & 0x20);
319  }
320 
325  inline int getLineZero() const {
326  return displayStart / TICKS_PER_LINE;
327  }
328 
333  inline bool isPalTiming() const {
334  return palTiming;
335  }
336 
344  inline bool isInterlaced() const {
345  return interlaced;
346  }
347 
358  inline bool isFastBlinkEnabled() const {
359  return (controlRegs[1] & 4) != 0;
360  }
361 
373  inline bool isEvenOddEnabled() const {
374  if (isFastBlinkEnabled()) return false;
375  return (controlRegs[9] & 4) != 0;
376  }
377 
381  inline bool getEvenOdd() const {
382  return (statusReg2 & 2) != 0;
383  }
384 
396  inline int getEvenOddMask() const {
397  // TODO: Verify which page is displayed on even fields.
398  assert(!isFastBlinkEnabled());
399  return (((~controlRegs[9] & 4) << 6) | ((statusReg2 & 2) << 7)) &
400  (!blinkState << 8);
401  }
402 
409  inline int getEvenOddMask(int line) const {
410  if (isFastBlinkEnabled()) {
411  // EO and IL not considered in this mode
412  auto p = calculateLineBlinkState(line);
413  return (!p.first) << 8;
414  } else {
415  return getEvenOddMask();
416  }
417  }
418 
423  inline std::pair<bool, int> calculateLineBlinkState(unsigned line) const {
424  assert(isFastBlinkEnabled());
425 
426  if (blinkCount == 0) { // not changing
427  return {blinkState, blinkCount};
428  }
429 
430  unsigned evenLen = ((controlRegs[13] >> 4) & 0x0F) * 10;
431  unsigned oddLen = ((controlRegs[13] >> 0) & 0x0F) * 10;
432  unsigned totalLen = evenLen + oddLen;
433  assert(totalLen != 0); // because this implies 'blinkCount == 0'
434  line %= totalLen; // reduce double flips
435 
436  bool resultState = blinkState; // initial guess, adjusted later
437  if (blinkState) {
438  // We start in the 'even' period -> check first for
439  // even/odd transition, next for odd/even
440  } else {
441  // We start in the 'odd' period -> do the opposite
442  std::swap(evenLen, oddLen);
443  }
444  int newCount = blinkCount - line;
445  if (newCount <= 0) {
446  // switch even->odd (or odd->even)
447  resultState = !resultState;
448  newCount += oddLen;
449  if (newCount <= 0) {
450  // switch odd->even (or even->odd)
451  resultState = !resultState;
452  newCount += evenLen;
453  assert(newCount > 0);
454  }
455  }
456  return {resultState, newCount};
457  }
458 
462  inline int getTicksThisFrame(EmuTime::param time) const {
463  return frameStartTime.getTicksTill_fast(time);
464  }
465 
466  inline EmuTime::param getFrameStartTime() const {
467  return frameStartTime.getTime();
468  }
469 
472  inline int getSpriteSize() const {
473  return ((controlRegs[1] & 2) << 2) + 8;
474  }
475 
478  inline bool isSpriteMag() const {
479  return controlRegs[1] & 1;
480  }
481 
485  inline bool getCmdBit() const {
486  return (controlRegs[25] & 0x40) != 0;
487  }
488 
491  inline int getLinesPerFrame() const {
492  return palTiming ? 313 : 262;
493  }
494 
497  inline int getTicksPerFrame() const {
498  return getLinesPerFrame() * TICKS_PER_LINE;
499  }
500 
510  inline bool isInsideFrame(EmuTime::param time) const {
511  return time >= frameStartTime.getTime() &&
513  }
514 
518  inline int getHorizontalAdjust() const {
519  return horizontalAdjust;
520  }
521 
529  inline int getLeftSprites() const {
530  return 100 + 102 + 56
531  + (horizontalAdjust - 7) * 4
532  + (displayMode.isTextMode() ? 36 : 0);
533  }
534 
540  inline int getLeftBorder() const {
541  return getLeftSprites() + (isBorderMasked() ? 8 * 4 : 0);
542  }
543 
547  inline int getRightBorder() const {
548  return getLeftSprites()
549  + (displayMode.isTextMode() ? 960 : 1024);
550  }
551 
557  inline int getLeftBackground() const {
558  return getLeftSprites() + getHorizontalScrollLow() * 4;
559  }
560 
564  byte getStatusReg0() const { return statusReg0; }
565 
574  void setSpriteStatus(byte value)
575  {
576  statusReg0 = (statusReg0 & 0x80) | (value & 0x7F);
577  }
578 
582  bool getVRMode() const {
583  return (controlRegs[8] & 8) != 0;
584  }
585 
588  void setExternalVideoSource(const RawFrame* externalSource) {
589  externalVideo = externalSource;
590  }
591 
594  bool getBrokenCmdTiming() const {
595  return brokenCmdTiming;
596  }
597 
600  EmuTime getAccessSlot(EmuTime::param time, VDPAccessSlots::Delta delta) const;
601 
612  EmuTime::param time, EmuTime::param limit) const;
613 
631  void scheduleCmdSync(EmuTime t) {
632  auto now = getCurrentTime();
633  if (t <= now) {
634  // The largest amount of VDP cycles between 'progress'
635  // in command emulation:
636  // - worst case the LMMM takes 120+64 cycles to fully process one pixel
637  // - the largest gap between access slots is 70 cycles
638  // - but if we're unlucky the CPU steals that slot
639  int LARGEST_STALL = 184 + 2 * 70;
640 
641  t = now + VDPClock::duration(LARGEST_STALL);
642  }
643  syncCmdDone.setSyncPoint(t);
644  }
645 
646  template<typename Archive>
647  void serialize(Archive& ar, unsigned version);
648 
649 private:
650  void initTables();
651 
652  // VdpVersion bitmasks
653  static constexpr unsigned VM_MSX1 = 1; // set-> MSX1, unset-> MSX2 or MSX2+
654  static constexpr unsigned VM_PAL = 2; // set-> fixed PAL, unset-> fixed NTSC or switchable
655  static constexpr unsigned VM_NO_MIRRORING = 4; // set-> no (screen2) mirroring
656  static constexpr unsigned VM_PALCOL_MIRRORING = 8; // set-> pattern/color-table mirroring
657  static constexpr unsigned VM_VRAM_REMAPPING = 16; // set-> 4k,8/16k VRAM remapping
658  static constexpr unsigned VM_TOSHIBA_PALETTE = 32; // set-> has Toshiba palette
659  static constexpr unsigned VM_YJK = 64; // set-> has YJK (MSX2+)
660  static constexpr unsigned VM_YM2220_PALETTE = 128; // set-> has YM2220 palette
661 
663  enum VdpVersion {
668  TMS99X8A = VM_MSX1 | VM_PALCOL_MIRRORING | VM_VRAM_REMAPPING,
669 
671  TMS9929A = VM_MSX1 | VM_PALCOL_MIRRORING | VM_VRAM_REMAPPING | VM_PAL,
672 
674  TMS9129 = VM_MSX1 | VM_PAL,
675 
677  TMS91X8 = VM_MSX1,
678 
680  T6950PAL = VM_MSX1 | VM_TOSHIBA_PALETTE | VM_NO_MIRRORING | VM_PAL,
681 
683  T6950NTSC = VM_MSX1 | VM_TOSHIBA_PALETTE | VM_NO_MIRRORING,
684 
686  T7937APAL = VM_MSX1 | VM_TOSHIBA_PALETTE | VM_PAL,
687 
689  T7937ANTSC = VM_MSX1 | VM_TOSHIBA_PALETTE,
690 
692  YM2220PAL = VM_MSX1 | VM_YM2220_PALETTE | VM_PALCOL_MIRRORING | VM_PAL,
693 
695  YM2220NTSC = VM_MSX1 | VM_YM2220_PALETTE | VM_PALCOL_MIRRORING,
696 
698  V9938 = 0,
699 
701  V9958 = VM_YJK,
702  };
703 
704  struct SyncBase : public Schedulable {
705  explicit SyncBase(VDP& vdp_) : Schedulable(vdp_.getScheduler()) {}
709  protected:
710  ~SyncBase() = default;
711  };
712 
713  struct SyncVSync final : public SyncBase {
714  explicit SyncVSync(VDP& vdp) : SyncBase(vdp) {}
715  void executeUntil(EmuTime::param time) override {
716  auto& vdp = OUTER(VDP, syncVSync);
717  vdp.execVSync(time);
718  }
719  } syncVSync;
720 
721  struct SyncDisplayStart final : public SyncBase {
722  explicit SyncDisplayStart(VDP& vdp) : SyncBase(vdp) {}
723  void executeUntil(EmuTime::param time) override {
724  auto& vdp = OUTER(VDP, syncDisplayStart);
725  vdp.execDisplayStart(time);
726  }
727  } syncDisplayStart;
728 
729  struct SyncVScan final : public SyncBase {
730  explicit SyncVScan(VDP& vdp) : SyncBase(vdp) {}
731  void executeUntil(EmuTime::param time) override {
732  auto& vdp = OUTER(VDP, syncVScan);
733  vdp.execVScan(time);
734  }
735  } syncVScan;
736 
737  struct SyncHScan final : public SyncBase {
738  explicit SyncHScan(VDP& vdp) : SyncBase(vdp) {}
739  void executeUntil(EmuTime::param /*time*/) override {
740  auto& vdp = OUTER(VDP, syncHScan);
741  vdp.execHScan();
742  }
743  } syncHScan;
744 
745  struct SyncHorAdjust final : public SyncBase {
746  explicit SyncHorAdjust(VDP& vdp) : SyncBase(vdp) {}
747  void executeUntil(EmuTime::param time) override {
748  auto& vdp = OUTER(VDP, syncHorAdjust);
749  vdp.execHorAdjust(time);
750  }
751  } syncHorAdjust;
752 
753  struct SyncSetMode final : public SyncBase {
754  explicit SyncSetMode(VDP& vdp) : SyncBase(vdp) {}
755  void executeUntil(EmuTime::param time) override {
756  auto& vdp = OUTER(VDP, syncSetMode);
757  vdp.execSetMode(time);
758  }
759  } syncSetMode;
760 
761  struct SyncSetBlank final : public SyncBase {
762  explicit SyncSetBlank(VDP& vdp) : SyncBase(vdp) {}
763  void executeUntil(EmuTime::param time) override {
764  auto& vdp = OUTER(VDP, syncSetBlank);
765  vdp.execSetBlank(time);
766  }
767  } syncSetBlank;
768 
769  struct SyncCpuVramAccess final : public SyncBase {
770  explicit SyncCpuVramAccess(VDP& vdp) : SyncBase(vdp) {}
771  void executeUntil(EmuTime::param time) override {
772  auto& vdp = OUTER(VDP, syncCpuVramAccess);
773  vdp.execCpuVramAccess(time);
774  }
775  } syncCpuVramAccess;
776 
777  struct SyncCmdDone final : public SyncBase {
778  explicit SyncCmdDone(VDP& vdp) : SyncBase(vdp) {}
779  void executeUntil(EmuTime::param time) override {
780  auto& vdp = OUTER(VDP, syncCmdDone);
781  vdp.execSyncCmdDone(time);
782  }
783  } syncCmdDone;
784 
785  void execVSync(EmuTime::param time);
786  void execDisplayStart(EmuTime::param time);
787  void execVScan(EmuTime::param time);
788  void execHScan();
789  void execHorAdjust(EmuTime::param time);
790  void execSetMode(EmuTime::param time);
791  void execSetBlank(EmuTime::param time);
792  void execCpuVramAccess(EmuTime::param time);
793  void execSyncCmdDone(EmuTime::param time);
794 
798  inline int getNumberOfLines() const {
799  return controlRegs[9] & 0x80 ? 212 : 192;
800  }
801 
805  int getVerticalAdjust() const {
806  return (controlRegs[18] >> 4) ^ 0x07;
807  }
808 
818  inline bool getHR(int ticksThisFrame) const {
819  // Note: These constants are located inside this function because
820  // GCC 4.0.x won't link if they are in the class scope.
824  static constexpr int HBLANK_LEN_TXT = 404;
828  static constexpr int HBLANK_LEN_GFX = 312;
829  return
830  ( ticksThisFrame + TICKS_PER_LINE - getRightBorder()
831  ) % TICKS_PER_LINE
832  < (displayMode.isTextMode() ? HBLANK_LEN_TXT : HBLANK_LEN_GFX);
833  }
834 
835  // VideoSystemChangeListener interface:
836  void preVideoSystemChange() override;
837  void postVideoSystemChange() override;
838 
843  void resetInit();
844 
849  void resetMasks(EmuTime::param time);
850 
854  void frameStart(EmuTime::param time);
855 
863  void scheduleDisplayStart(EmuTime::param time);
864 
870  void scheduleVScan(EmuTime::param time);
871 
877  void scheduleHScan(EmuTime::param time);
878 
881  void vramWrite(byte value, EmuTime::param time);
882 
885  byte vramRead(EmuTime::param time);
886 
888  void scheduleCpuVramAccess(bool isRead, byte write, EmuTime::param time);
889  void executeCpuVramAccess(EmuTime::param time);
890 
893  byte peekStatusReg(byte reg, EmuTime::param time) const;
894  byte readStatusReg(byte reg, EmuTime::param time);
895 
898  void changeRegister(byte reg, byte val, EmuTime::param time);
899 
902  void syncAtNextLine(SyncBase& type, EmuTime::param time);
903 
906  void createRenderer();
907 
911  void updateNameBase(EmuTime::param time);
912 
916  void updateColorBase(EmuTime::param time);
917 
921  void updatePatternBase(EmuTime::param time);
922 
926  void updateSpriteAttributeBase(EmuTime::param time);
927 
931  void updateSpritePatternBase(EmuTime::param time);
932 
936  void updateDisplayMode(DisplayMode newMode, bool cmdBit, EmuTime::param time);
937 
944  void setPalette(int index, word grb, EmuTime::param time);
945 
946  // Observer<Setting>
947  void update(const Setting& setting) override;
948 
949 private:
950  Display& display;
951  EnumSetting<bool>& cmdTiming;
952  EnumSetting<bool>& tooFastAccess;
953 
954  struct RegDebug final : SimpleDebuggable {
955  explicit RegDebug(VDP& vdp);
956  byte read(unsigned address) override;
957  void write(unsigned address, byte value, EmuTime::param time) override;
958  } vdpRegDebug;
959 
960  struct StatusRegDebug final : SimpleDebuggable {
961  explicit StatusRegDebug(VDP& vdp);
962  byte read(unsigned address, EmuTime::param time) override;
963  } vdpStatusRegDebug;
964 
965  struct PaletteDebug final : SimpleDebuggable {
966  explicit PaletteDebug(VDP& vdp);
967  byte read(unsigned address) override;
968  void write(unsigned address, byte value, EmuTime::param time) override;
969  } vdpPaletteDebug;
970 
971  struct VRAMPointerDebug final : SimpleDebuggable {
972  explicit VRAMPointerDebug(VDP& vdp);
973  byte read(unsigned address) override;
974  void write(unsigned address, byte value, EmuTime::param time) override;
975  } vramPointerDebug;
976 
977  class Info : public InfoTopic {
978  public:
979  void execute(span<const TclObject> tokens,
980  TclObject& result) const override;
981  std::string help(const std::vector<std::string>& tokens) const override;
982  virtual int calc(const EmuTime& time) const = 0;
983  protected:
984  Info(VDP& vdp_, const std::string& name, std::string helpText_);
985  ~Info() = default;
986  VDP& vdp;
987  const std::string helpText;
988  };
989 
990  struct FrameCountInfo final : Info {
991  explicit FrameCountInfo(VDP& vdp);
992  int calc(const EmuTime& time) const override;
993  } frameCountInfo;
994 
995  struct CycleInFrameInfo final : Info {
996  explicit CycleInFrameInfo(VDP& vdp);
997  int calc(const EmuTime& time) const override;
998  } cycleInFrameInfo;
999 
1000  struct LineInFrameInfo final : Info {
1001  explicit LineInFrameInfo(VDP& vdp);
1002  int calc(const EmuTime& time) const override;
1003  } lineInFrameInfo;
1004 
1005  struct CycleInLineInfo final : Info {
1006  explicit CycleInLineInfo(VDP& vdp);
1007  int calc(const EmuTime& time) const override;
1008  } cycleInLineInfo;
1009 
1010  struct MsxYPosInfo final : Info {
1011  explicit MsxYPosInfo(VDP& vdp);
1012  int calc(const EmuTime& time) const override;
1013  } msxYPosInfo;
1014 
1015  struct MsxX256PosInfo final : Info {
1016  explicit MsxX256PosInfo(VDP& vdp);
1017  int calc(const EmuTime& time) const override;
1018  } msxX256PosInfo;
1019 
1020  struct MsxX512PosInfo final : Info {
1021  explicit MsxX512PosInfo(VDP& vdp);
1022  int calc(const EmuTime& time) const override;
1023  } msxX512PosInfo;
1024 
1027  std::unique_ptr<Renderer> renderer;
1028 
1031  std::unique_ptr<VDPCmdEngine> cmdEngine;
1032 
1035  std::unique_ptr<SpriteChecker> spriteChecker;
1036 
1039  std::unique_ptr<VDPVRAM> vram;
1040 
1044  const RawFrame* externalVideo;
1045 
1051  const RawFrame* superimposing;
1052 
1055  VDPClock frameStartTime;
1056 
1059  OptionalIRQHelper irqVertical;
1060 
1063  OptionalIRQHelper irqHorizontal;
1064 
1067  EmuTime displayStartSyncTime;
1068 
1071  EmuTime vScanSyncTime;
1072 
1075  EmuTime hScanSyncTime;
1076 
1077  TclCallback tooFastCallback;
1078 
1081  VdpVersion version;
1082 
1087  int saturationPr;
1088 
1093  int saturationPb;
1094 
1100  int frameCount;
1101 
1104  int displayStart;
1105 
1109  int horizontalScanOffset;
1110 
1114  int horizontalAdjust;
1115 
1118  byte controlRegs[32];
1119 
1124  int controlRegMask;
1125 
1132  byte controlValueMasks[32];
1133 
1137  int blinkCount;
1138 
1142  int vramPointer;
1143 
1146  word palette[16];
1147 
1150  bool isDisplayArea;
1151 
1157  bool palTiming;
1158 
1162  bool interlaced;
1163 
1168  byte statusReg0;
1169 
1175  byte statusReg1;
1176 
1181  byte statusReg2;
1182 
1185  bool blinkState;
1186 
1189  byte dataLatch;
1190 
1193  bool registerDataStored;
1194 
1197  bool paletteDataStored;
1198 
1206  byte cpuVramData;
1207 
1211  bool cpuVramReqIsRead;
1212  bool pendingCpuAccess; // always equal to pendingSyncPoint(CPU_VRAM_ACCESS)
1213 
1217  bool cpuExtendedVram;
1218 
1224  DisplayMode displayMode;
1225 
1230  bool displayEnabled;
1231 
1235  bool warningPrinted;
1236 
1238  bool brokenCmdTiming;
1239  bool allowTooFastAccess;
1240 
1242  MSXCPU& cpu;
1243  const byte fixedVDPIOdelayCycles;
1244 };
1246 
1247 } // namespace openmsx
1248 
1249 #endif
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:31
openmsx::VDP::canSpriteColor0Collide
bool canSpriteColor0Collide() const
Can a sprite which has color=0 collide with some other sprite?
Definition: VDP.hh:180
openmsx::VDPVRAM
Manages VRAM contents and synchronises the various users of the VRAM.
Definition: VDPVRAM.hh:384
openmsx::VDP::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: VDP.cc:954
openmsx::VDP::scheduleCmdSync
void scheduleCmdSync(EmuTime t)
Only used when there are commandExecuting-probe listeners.
Definition: VDP.hh:631
openmsx.hh
openmsx::Clock::getTime
constexpr EmuTime::param getTime() const
Gets the time at which the last clock tick occurred.
Definition: Clock.hh:46
Clock.hh
openmsx::VDPVRAM
VDPVRAM
Definition: VDPVRAM.cc:343
openmsx::VDP::getSpriteSize
int getSpriteSize() const
Gets the sprite size in pixels (8/16).
Definition: VDP.hh:472
openmsx::VDP::getEvenOddMask
int getEvenOddMask(int line) const
Similar to the above getEvenOddMask() method, but can also be called when 'isFastBlinkEnabled() == tr...
Definition: VDP.hh:409
openmsx::VDP
Unified implementation of MSX Video Display Processors (VDPs).
Definition: VDP.hh:61
openmsx::VDP::getHorizontalScrollLow
byte getHorizontalScrollLow() const
Gets the current horizontal scroll lower bits.
Definition: VDP.hh:289
openmsx::VDP::getHorizontalScrollHigh
byte getHorizontalScrollHigh() const
Gets the current horizontal scroll higher bits.
Definition: VDP.hh:298
openmsx::VDP::TICKS_PER_SECOND
static constexpr int TICKS_PER_SECOND
Number of VDP clock ticks per second.
Definition: VDP.hh:67
openmsx::MSXDevice::getScheduler
Scheduler & getScheduler() const
Definition: MSXDevice.cc:143
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::VDP::isInterlaced
bool isInterlaced() const
Get interlace status.
Definition: VDP.hh:344
openmsx::VDP::getEvenOdd
bool getEvenOdd() const
Is the even or odd field being displayed?
Definition: VDP.hh:381
openmsx::VDP::isPalTiming
bool isPalTiming() const
Is PAL timing active? This setting is fixed at start of frame.
Definition: VDP.hh:333
openmsx::SpriteChecker
SpriteChecker
Definition: SpriteChecker.cc:524
openmsx::VDP::calculateLineBlinkState
std::pair< bool, int > calculateLineBlinkState(unsigned line) const
Calculates what 'blinkState' and 'blinkCount' would be at a specific line.
Definition: VDP.hh:423
openmsx::VDP::vdpLacksMirroring
bool vdpLacksMirroring() const
Is this a VDP that lacks mirroring?
Definition: VDP.hh:107
openmsx::VDP::isBorderMasked
bool isBorderMasked() const
Gets the current border mask setting.
Definition: VDP.hh:307
openmsx::VDP::getBackgroundColor
int getBackgroundColor() const
Gets the current background color.
Definition: VDP.hh:204
t
TclObject t
Definition: TclObject_test.cc:264
openmsx::VDP::getMSX1Palette
std::array< std::array< uint8_t, 3 >, 16 > getMSX1Palette() const
Get the (fixed) palette for this MSX1 VDP.
Definition: VDP.cc:1513
Schedulable.hh
openmsx::VDP::getPalette
word getPalette(int index) const
Gets a palette entry.
Definition: VDP.hh:239
openmsx::VDP::getTicksPerFrame
int getTicksPerFrame() const
Gets the number of VDP clockticks (21MHz) per frame.
Definition: VDP.hh:497
openmsx::VDP::isVDPwithPALonly
bool isVDPwithPALonly() const
Is this a VDP only capable of PAL?
Definition: VDP.hh:100
openmsx::VDP::setSpriteStatus
void setSpriteStatus(byte value)
Should only be used by SpriteChecker.
Definition: VDP.hh:574
openmsx::VDP::getHorizontalAdjust
int getHorizontalAdjust() const
This is a combination of the (horizontal) set adjust register and the YJK-mode bit.
Definition: VDP.hh:518
openmsx::VDP::getAccessSlotCalculator
VDPAccessSlots::Calculator getAccessSlotCalculator(EmuTime::param time, EmuTime::param limit) const
Same as getAccessSlot(), but it can be much faster for repeated calls, e.g.
Definition: VDP.cc:865
openmsx::VDP::spritesEnabled
bool spritesEnabled() const
Are sprites enabled?
Definition: VDP.hh:256
openmsx::MSXCPU
MSXCPU
Definition: MSXCPU.cc:563
VideoSystemChangeListener.hh
openmsx::VDP::getDisplayMode
DisplayMode getDisplayMode() const
Get the display mode the VDP is in.
Definition: VDP.hh:141
openmsx::VDP::getVRMode
bool getVRMode() const
Returns current VR mode.
Definition: VDP.hh:582
openmsx::DisplayMode::GRAPHIC7
@ GRAPHIC7
Definition: DisplayMode.hh:38
openmsx::DisplayMode
Represents a VDP display mode.
Definition: DisplayMode.hh:15
span
Definition: span.hh:34
DisplayMode.hh
openmsx::SERIALIZE_CLASS_VERSION
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
openmsx::SimpleDebuggable::read
virtual byte read(unsigned address, EmuTime::param time)
Definition: SimpleDebuggable.cc:39
openmsx::Schedulable::setSyncPoint
void setSyncPoint(EmuTime::param timestamp)
Definition: Schedulable.cc:23
openmsx::VDPAccessSlots::Calculator
VDP-VRAM access slot calculator, meant to be used in the inner loops of the VDPCmdEngine commands.
Definition: VDPAccessSlots.hh:37
OUTER
#define OUTER(type, member)
Definition: outer.hh:41
openmsx::VDP::isDisplayEnabled
bool isDisplayEnabled() const
Is the display enabled? Both the regular border and forced blanking by clearing the display enable bi...
Definition: VDP.hh:248
Observer.hh
openmsx::VDP::powerUp
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
Definition: VDP.cc:314
openmsx::VDP::getLinesPerFrame
int getLinesPerFrame() const
Gets the number of lines per frame.
Definition: VDP.hh:491
openmsx::VDP::isFastBlinkEnabled
bool isFastBlinkEnabled() const
Get 'fast-blink' status.
Definition: VDP.hh:358
openmsx::VDPCmdEngine
VDPCmdEngine
Definition: VDPCmdEngine.cc:2646
openmsx::VDP::getLineZero
int getLineZero() const
Get the absolute line number of display line zero.
Definition: VDP.hh:325
openmsx::VDP::spritesEnabledRegister
bool spritesEnabledRegister() const
Still faster variant (just looks at the sprite-enabled-bit).
Definition: VDP.hh:273
openmsx::MSXDevice::getCurrentTime
EmuTime::param getCurrentTime() const
Definition: MSXDevice.cc:131
openmsx::VDP::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: VDP.cc:320
openmsx::VDP::getVRAM
VDPVRAM & getVRAM()
Get the VRAM object for this VDP.
Definition: VDP.hh:147
MSXDevice.hh
openmsx::SpriteChecker
Definition: SpriteChecker.hh:18
openmsx::SimpleDebuggable::write
void write(unsigned address, byte value) override
Definition: SimpleDebuggable.cc:44
openmsx::Schedulable::pendingSyncPoint
bool pendingSyncPoint() const
Definition: Schedulable.cc:38
openmsx::VDP::getForegroundColor
int getForegroundColor() const
Gets the current foreground color.
Definition: VDP.hh:192
openmsx::VDP::getBlinkState
bool getBlinkState() const
Gets the current blink state.
Definition: VDP.hh:230
openmsx::PostProcessor
Abstract base class for post processors.
Definition: PostProcessor.hh:29
openmsx::VDP::isMSX1VDP
bool isMSX1VDP() const
Is this an MSX1 VDP?
Definition: VDP.hh:93
openmsx::VDP::~VDP
~VDP() override
Definition: VDP.cc:218
openmsx::VDP::isSuperimposing
const RawFrame * isSuperimposing() const
Are we currently superimposing? In case of superimpose, returns a pointer to the to-be-superimposed f...
Definition: VDP.hh:155
openmsx::RawFrame
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:25
SimpleDebuggable.hh
openmsx::VDP::getBlinkBackgroundColor
int getBlinkBackgroundColor() const
Gets the current blinking color for blinking text.
Definition: VDP.hh:223
openmsx::Clock< TICKS_PER_SECOND >::duration
static constexpr EmuDuration duration(unsigned ticks)
Calculates the duration of the given number of ticks at this clock's frequency.
Definition: Clock.hh:35
openmsx::DisplayMode::isTextMode
constexpr bool isTextMode() const
Is the current mode a text mode? Text1 and Text2 are text modes.
Definition: DisplayMode.hh:130
openmsx::VDP::writeIO
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
Definition: VDP.cc:643
openmsx::VDP::hasYJK
bool hasYJK() const
Does this VDP support YJK display?
Definition: VDP.hh:128
openmsx::VDP::isSpriteMag
bool isSpriteMag() const
Are sprites magnified?
Definition: VDP.hh:478
outer.hh
TclCallback.hh
openmsx::VDP::isMultiPageScrolling
bool isMultiPageScrolling() const
Is multi page scrolling enabled? It is considered enabled if both the multi page scrolling flag is en...
Definition: VDP.hh:317
openmsx::Schedulable
Schedulable
Definition: Schedulable.cc:69
openmsx::VDP::getFrameStartTime
EmuTime::param getFrameStartTime() const
Definition: VDP.hh:466
openmsx::VDP::getRightBorder
int getRightBorder() const
Gets the number of VDP clockticks between start of line and the start of the right border.
Definition: VDP.hh:547
openmsx::VDP::getLeftSprites
int getLeftSprites() const
Gets the number of VDP clockticks between start of line and the start of the sprite plane.
Definition: VDP.hh:529
openmsx::VDP::VDPClock
Clock< TICKS_PER_SECOND > VDPClock
Definition: VDP.hh:68
openmsx::VDP::getTransparency
bool getTransparency() const
Gets the current transparency setting.
Definition: VDP.hh:174
openmsx::VDP::getTicksThisFrame
int getTicksThisFrame(EmuTime::param time) const
Gets the number of VDP clock ticks (21MHz) elapsed between a given time and the start of this frame.
Definition: VDP.hh:462
openmsx::VDP
VDP
Definition: VDP.cc:1917
openmsx::VDP::getLeftBackground
int getLeftBackground() const
Gets the number of VDP clockticks between start of line and the time when the background pixel with X...
Definition: VDP.hh:557
openmsx::VDP::isEvenOddEnabled
bool isEvenOddEnabled() const
Get even/odd page alternation status.
Definition: VDP.hh:373
openmsx::VDP::getPostProcessor
PostProcessor * getPostProcessor() const
Used by Video9000 to be able to couple the VDP and V9990 output.
Definition: VDP.cc:244
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::VDP::getStatusReg0
byte getStatusReg0() const
Should only be used by SpriteChecker.
Definition: VDP.hh:564
openmsx::VDP::getAccessSlot
EmuTime getAccessSlot(EmuTime::param time, VDPAccessSlots::Delta delta) const
Get the earliest access slot that is at least 'delta' cycles in the future.
Definition: VDP.cc:859
openmsx::VDP::getVerticalScroll
byte getVerticalScroll() const
Gets the current vertical scroll (line displayed at Y=0).
Definition: VDP.hh:280
InfoTopic.hh
openmsx::VDP::VDP
VDP(const DeviceConfig &config)
Definition: VDP.cc:65
openmsx::Clock::getTicksTill_fast
constexpr unsigned getTicksTill_fast(EmuTime::param e) const
Same as above, only faster, Though the time interval may not be too large.
Definition: Clock.hh:70
openmsx::DisplayMode::getSpriteMode
constexpr int getSpriteMode(bool isMSX1) const
Get the sprite mode of this display mode.
Definition: DisplayMode.hh:166
openmsx::VDP::getEvenOddMask
int getEvenOddMask() const
Expresses the state of even/odd page interchange in a mask on the line number.
Definition: VDP.hh:396
openmsx::VDP::getSpriteChecker
SpriteChecker & getSpriteChecker()
Get the sprite checker for this VDP.
Definition: VDP.hh:167
openmsx::VDP::vdpHasPatColMirroring
bool vdpHasPatColMirroring() const
Is this a VDP that has pattern/colortable mirroring?
Definition: VDP.hh:114
openmsx::VDP::isInsideFrame
bool isInsideFrame(EmuTime::param time) const
Is the given timestamp inside the current frame? Mainly useful for debugging, because relevant timest...
Definition: VDP.hh:510
openmsx::VDP::getCmdBit
bool getCmdBit() const
Are commands possible in non Graphic modes? (V9958 only)
Definition: VDP.hh:485
openmsx::VDP::setExternalVideoSource
void setExternalVideoSource(const RawFrame *externalSource)
Enable superimposing.
Definition: VDP.hh:588
IRQHelper.hh
openmsx::VDP::spritesEnabledFast
bool spritesEnabledFast() const
Same as spritesEnabled(), but may only be called in sprite mode 1 or 2.
Definition: VDP.hh:265
openmsx::VDP::getBlinkForegroundColor
int getBlinkForegroundColor() const
Gets the current blinking color for blinking text.
Definition: VDP.hh:216
openmsx::VDP::getLeftBorder
int getLeftBorder() const
Gets the number of VDP clockticks between start of line and the end of the left border.
Definition: VDP.hh:540
openmsx::VideoSystemChangeListener
Definition: VideoSystemChangeListener.hh:6
openmsx::DisplayMode::getByte
constexpr byte getByte() const
Get the dispay mode as a byte: YAE YJK M5..M1 combined.
Definition: DisplayMode.hh:101
openmsx::VDP::TICKS_PER_LINE
static constexpr int TICKS_PER_LINE
Number of VDP clock ticks per line.
Definition: VDP.hh:72
openmsx::VDP::getBrokenCmdTiming
bool getBrokenCmdTiming() const
Value of the cmdTiming setting, true means commands have infinite speed.
Definition: VDP.hh:594
openmsx::VDP::isVDPwithVRAMremapping
bool isVDPwithVRAMremapping() const
Does this VDP have VRAM remapping when switching from 4k to 8/16k mode?
Definition: VDP.hh:121
openmsx::Clock< TICKS_PER_SECOND >
openmsx::VDP::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: VDP.cc:974
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::VDPAccessSlots::Delta
Delta
Definition: VDPAccessSlots.hh:13
openmsx::OptionalIRQHelper
IntHelper< OptionalIRQ > OptionalIRQHelper
Definition: IRQHelper.hh:136
openmsx::Observer
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
openmsx::SimpleDebuggable::read
byte read(unsigned address) override
Definition: SimpleDebuggable.cc:34
openmsx::Schedulable::removeSyncPoint
bool removeSyncPoint()
Definition: Schedulable.cc:28
openmsx::VDP::serialize
void serialize(Archive &ar, unsigned version)
Definition: VDP.cc:1824