From e3ef2ee31ce91a2d7e69d79a16ddd06a7113a71c Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Tue, 31 Dec 2019 00:25:24 +0100 Subject: [PATCH] replace magic number for Lightgun --- src/emucore/Lightgun.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/emucore/Lightgun.cxx b/src/emucore/Lightgun.cxx index 41fc5a882..faf63e92e 100644 --- a/src/emucore/Lightgun.cxx +++ b/src/emucore/Lightgun.cxx @@ -15,7 +15,6 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ - #include "Event.hxx" #include "TIA.hxx" #include "FrameBuffer.hxx" @@ -43,15 +42,17 @@ bool Lightgun::read(DigitalPin pin) { case DigitalPin::Six: // INPT4/5 { + TIA& tia = mySystem.tia(); const Common::Rect& rect = myFrameBuffer.imageRect(); // scale mouse coordinates into TIA coordinates Int32 xMouse = (myEvent.get(Event::MouseAxisXValue) - rect.x()) - * TIAConstants::H_PIXEL / rect.w(); + * tia.width() / rect.w(); Int32 yMouse = (myEvent.get(Event::MouseAxisYValue) - rect.y()) - * 210 / rect.h(); // TODO: replace "magic number" + * tia.height() / rect.h(); + // get adjusted TIA coordinates - Int32 xTia = mySystem.tia().clocksThisLine() - TIAConstants::H_BLANK_CLOCKS + X_OFS; - Int32 yTia = mySystem.tia().scanlines() - mySystem.tia().startLine() + Y_OFS; + Int32 xTia = tia.clocksThisLine() - TIAConstants::H_BLANK_CLOCKS + X_OFS; + Int32 yTia = tia.scanlines() - tia.startLine() + Y_OFS; if (xTia < 0) xTia += TIAConstants::H_CLOCKS;