From 4cd66f6809a5b51cd00669822985f333181892ee Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Wed, 20 Jan 2021 22:05:50 -0500 Subject: [PATCH] improving the paddle bios config --- bios.cpp | 37 ++++++++++++++++++++++++++++++++----- sdl/sdl-keyboard.cpp | 13 +++++++++++-- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/bios.cpp b/bios.cpp index 56b13c4..916b941 100644 --- a/bios.cpp +++ b/bios.cpp @@ -659,12 +659,14 @@ uint16_t BIOS::PaddlesScreenHandler(bool needsRedraw, bool performAction) static uint8_t lastPaddleX = g_paddles->paddle0(); static uint8_t lastPaddleY = g_paddles->paddle1(); - if (g_paddles->paddle0() != lastPaddleX) { - lastPaddleX = g_paddles->paddle0(); + uint8_t paddle = g_paddles->paddle0(); + if (paddle != lastPaddleX) { + lastPaddleX = paddle; localRedraw = true; } - if (g_paddles->paddle1() != lastPaddleY) { - lastPaddleY = g_paddles->paddle1(); + paddle = g_paddles->paddle1(); + if (paddle != lastPaddleY) { + lastPaddleY = paddle; localRedraw = true; } @@ -675,7 +677,32 @@ uint16_t BIOS::PaddlesScreenHandler(bool needsRedraw, bool performAction) g_display->drawString(M_NORMAL, 0, 12, buf); sprintf(buf, "Paddle Y: %d ", lastPaddleY); g_display->drawString(M_NORMAL, 0, 42, buf); - g_display->drawString(M_NORMAL, 0, 92, "Press return to exit"); + g_display->drawString(M_NORMAL, 0, 132, "Press return to exit"); + + // Draw the target for the paddle position + for (uint16_t y=10; y<=110; y++) { + for (uint16_t x=160; x<=260; x++) { + g_display->drawUIPixel(x, y, 0x0000); + g_display->drawUIPixel(x, 10, 0xFFFF); + g_display->drawUIPixel(x, 110, 0xFFFF); + } + g_display->drawUIPixel(160, y, 0xFFFF); + g_display->drawUIPixel(260, y, 0xFFFF); + } + + for (uint16_t y=57; y<=63; y++) { + g_display->drawUIPixel(207,y,0xFFFF); + g_display->drawUIPixel(213,y,0xFFFF); + } + for (uint16_t x=207; x<=213; x++) { + g_display->drawUIPixel(x,57,0xFFFF); + g_display->drawUIPixel(x,63,0xFFFF); + } + + float drawX = ((float)lastPaddleX/255.0)*100.0; + float drawY = ((float)lastPaddleY/255.0)*100.0; + g_display->drawUIPixel(160+drawX, 10+drawY, 0xFFFF); + g_display->flush(); localRedraw = false; diff --git a/sdl/sdl-keyboard.cpp b/sdl/sdl-keyboard.cpp index cd486bd..47a7c90 100644 --- a/sdl/sdl-keyboard.cpp +++ b/sdl/sdl-keyboard.cpp @@ -189,8 +189,17 @@ bool SDLKeyboard::kbhit() if (event.type == SDL_QUIT) { exit(0); } - - if (event.type == SDL_KEYDOWN) { + + if (event.type == SDL_MOUSEMOTION) { + // We are handling the SDL input loop, so need to pass this off to the paddles. :/ + // FIXME: nasty rooting around in other objects and typecasting. + // FIXME: event.motion.state & SDL_BUTTON_LMASK, et al? + + ((SDLPaddles *)g_paddles)->gotMouseMovement(event.motion.x, event.motion.y); + ((SDLMouse *)g_mouse)->gotMouseEvent(event.motion.state, // button + event.motion.xrel, event.motion.yrel); + + } else if (event.type == SDL_KEYDOWN) { SDL_KeyboardEvent *key = &event.key; if ( (key->keysym.sym >= 'a' && key->keysym.sym <= 'z') ||