fix crash when light gun game is started from command line

This commit is contained in:
thrust26 2020-01-01 15:27:42 +01:00
parent 7c938de49b
commit c147588a7d
2 changed files with 16 additions and 2 deletions

View File

@ -42,8 +42,13 @@ bool Lightgun::read(DigitalPin pin)
{
case DigitalPin::Six: // INPT4/5
{
TIA& tia = mySystem.tia();
const Common::Rect& rect = myFrameBuffer.imageRect();
// abort when no valid framebuffer exists
if (rect.w() == 0 || rect.h() == 0)
return false;
TIA& tia = mySystem.tia();
// scale mouse coordinates into TIA coordinates
Int32 xMouse = (myEvent.get(Event::MouseAxisXValue) - rect.x())
* tia.width() / rect.w();
@ -72,5 +77,7 @@ void Lightgun::update()
// we allow left and right mouse buttons for fire button
setPin(DigitalPin::One, myEvent.get(Event::MouseButtonLeftValue)
|| myEvent.get(Event::MouseButtonRightValue));
cerr << mySystem.tia().startLine() << endl;
}

View File

@ -62,8 +62,15 @@ public:
private:
const FrameBuffer& myFrameBuffer;
// Shooting Arcade:
static constexpr Int32 X_OFS = -21;
static constexpr Int32 Y_OFS = 5;
static constexpr Int32 Y_OFS = 5; // 260 scanlines
// Guntest:
//static constexpr Int32 X_OFS = -25;
//static constexpr Int32 Y_OFS = 1; // 262 scanlines
// Sentinel:
//static constexpr Int32 X_OFS = -24;
//static constexpr Int32 Y_OFS = -5; // 268 scanlines
private:
// Following constructors and assignment operators not supported