19 , videoSourceSetting(getMotherBoard().getVideoSource())
20 , activeLayer(nullptr)
35 if (refs.size() != 2) error =
true;
36 if (!error && !
dynamic_cast<VDP*
>(refs[0])) {
37 std::swap(refs[0], refs[1]);
39 if (!error) vdp =
dynamic_cast<VDP*
>(refs[0]);
40 if (!error) v9990 =
dynamic_cast<V9990*
>(refs[1]);
41 if (error || !vdp || !v9990) {
43 "Invalid Video9000 configuration: "
44 "need reference to VDP and V9990 device.");
62 if (newValue == value)
return;
67 void Video9000::recalc()
72 assert(!!v99x8Layer == !!v9990Layer);
77 bool showV99x8 = ((value & 0x10) == 0x10);
78 bool showV9990 = ((value & 0x18) != 0x10);
79 assert(showV99x8 || showV9990);
88 activeLayer = showV9990 ? v9990Layer : v99x8Layer;
93 void Video9000::recalcVideoSource()
98 bool superimpose = ((value & 0x18) == 0x18);
103 void Video9000::preVideoSystemChange() noexcept
105 activeLayer =
nullptr;
108 void Video9000::postVideoSystemChange() noexcept
114 void Video9000::paint(OutputSurface& output)
121 activeLayer->
paint(output);
124 void Video9000::takeRawScreenShot(
unsigned height,
const std::string&
filename)
126 auto* layer =
dynamic_cast<VideoLayer*
>(activeLayer);
128 throw CommandException(
"TODO");
130 layer->takeRawScreenShot(height,
filename);
133 int Video9000::signalEvent(
const Event& event) noexcept
135 int video9000id = getVideoSource();
138 const auto& ffe = get<FinishFrameEvent>(event);
139 if (ffe.isSkipped())
return 0;
140 if (videoSourceSetting.getSource() != video9000id)
return 0;
142 bool superimpose = ((value & 0x18) == 0x18);
143 if (superimpose && v99x8Layer && v9990Layer &&
144 (ffe.getSource() == v99x8Layer->getVideoSource())) {
146 v9990Layer->setSuperimposeVdpFrame(v99x8Layer->getPaintFrame());
149 bool showV9990 = ((value & 0x18) != 0x10);
150 if (( showV9990 && v9990Layer && (ffe.getSource() == v9990Layer->getVideoSource())) ||
151 (!showV9990 && v99x8Layer && (ffe.getSource() == v99x8Layer->getVideoSource()))) {
152 getReactor().getEventDistributor().distributeEvent(
153 Event::create<FinishFrameEvent>(video9000id, video9000id,
false));
158 void Video9000::update(
const Setting&
setting) noexcept
161 if (&
setting == &videoSourceSetting) {
166 template<
typename Archive>
169 ar.template serializeBase<MSXDevice>(*
this);
170 ar.serialize(
"value", value);
171 if constexpr (Archive::IS_LOADER) {
void detach(VideoSystemChangeListener &listener)
void attach(VideoSystemChangeListener &listener)
void unregisterEventListener(EventType type, EventListener &listener)
Unregisters a previously registered event listener.
void registerEventListener(EventType type, EventListener &listener, Priority priority=OTHER)
Registers a given object to receive certain events.
virtual void paint(OutputSurface &output)=0
Paint this layer.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Reactor & getReactor() const
const Devices & getReferences() const
Get the device references that are specified for this device.
EventDistributor & getEventDistributor()
Implementation of the Yamaha V9990 VDP as used in the GFX9000 cartridge by Sunrise.
void setExternalVideoSource(bool enable)
Is there an external video source available to superimpose on.
PostProcessor * getPostProcessor() const
Used by Video9000 to be able to couple the VDP and V9990 output.
Unified implementation of MSX Video Display Processors (VDPs).
PostProcessor * getPostProcessor() const
Used by Video9000 to be able to couple the VDP and V9990 output.
Video9000(const DeviceConfig &config)
void reset(EmuTime::param time) override
This method is called on reset.
void serialize(Archive &ar, unsigned version)
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.
int getVideoSource() const
Returns the ID for this videolayer.
void setVideo9000Active(int video9000Source_, Video9000Active active)
void update(const Setting &setting) noexcept override
VideoLayer(const VideoLayer &)=delete
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
constexpr const char *const filename
uint16_t word
16 bit unsigned integer
EventType getType(const Event &event)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)