diff --git a/src/apple2.cpp b/src/apple2.cpp index 361a17f..9c5d201 100644 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -33,6 +33,7 @@ #include "diskcontroller.h" #include "languagecard.h" #include "screenimage.h" +#include "KeyRepeatHandler.h" #include #include @@ -41,6 +42,7 @@ Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates, AnalogTV& tv, KeyboardBufferMode& buffered, ScreenImage& gui) : slts(gui), kbd(keypresses, buffered), +keyrepeater(keypresses), rom(AddressBus::MOTHERBOARD_ROM_SIZ), ram(revision), cassetteIn(gui), @@ -83,6 +85,7 @@ void Apple2::tick() { this->speaker.tick(); this->cassetteIn.tick(); this->cassetteOut.tick(); + this->keyrepeater.tick(); if (this->revision > 0) { this->powerUpReset.tick(); diff --git a/src/apple2.h b/src/apple2.h index 1031090..5734956 100644 --- a/src/apple2.h +++ b/src/apple2.h @@ -22,6 +22,7 @@ #include "slots.h" #include "videomode.h" #include "keyboard.h" +#include "KeyRepeatHandler.h" #include "addressbus.h" #include "memory.h" #include "memoryrandomaccess.h" @@ -49,6 +50,7 @@ class Apple2 : public Timable Slots slts; VideoMode videoMode; Keyboard kbd; + KeyRepeatHandler keyrepeater; Paddles paddles; SpeakerClicker speaker; Memory rom; @@ -77,6 +79,8 @@ public: virtual void tick(); + KeyRepeatHandler &rept() { return this->keyrepeater; } + friend class Emulator; }; diff --git a/src/emulator.cpp b/src/emulator.cpp index 21bbd2f..7bbee5a 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -53,7 +53,6 @@ Emulator::Emulator() : videoStatic(display), apple2(keypresses, paddleButtonStates, display, buffered, screenImage), timable(nullptr), // No ticked object (NULL pointer) - keyrepeater(keypresses), keysDown(0), prev_ms(SDL_GetTicks()) { } @@ -110,7 +109,6 @@ void Emulator::tick50ms() { if (this->timable) { for (int i = 0; i < CHECK_EVERY_CYCLE; ++i) { this->timable->tick(); // this runs the emulator! - this->keyrepeater.tick(); // TODO move into Apple2 } } @@ -208,7 +206,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) { } const SDL_Keycode sym = keyEvent.keysym.sym; - const SDL_Keymod mod = (SDL_Keymod) keyEvent.keysym.mod; + const SDL_Keymod mod = (SDL_Keymod)keyEvent.keysym.mod; //printf("keydown: mod: %04X sym: %08X scan:%04X name:%s\n", mod, sym, scan, SDL_GetKeyName(sym)); @@ -217,7 +215,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) { } if (sym == SDLK_F10) { - this->keyrepeater.press(); + this->apple2.rept().press(); // } else if (SDLK_F1 <= sym && sym <= SDLK_F12) { // wxGetApp().OnFnKeyPressed(sym); } else { @@ -226,7 +224,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) { if (sendKey) { //printf(" sending to apple as ASCII ------------------------------> %02X (%02X) (%d)\n", key, key | 0x80, key | 0x80); this->keypresses.push(key); - this->keyrepeater.setKey(key); + this->apple2.rept().setKey(key); } } } @@ -238,12 +236,12 @@ void Emulator::dispatchKeyUp(const SDL_KeyboardEvent& keyEvent) { if (isKeyDown(sym, mod)) { --this->keysDown; if (this->keysDown <= 0) { - this->keyrepeater.clearKey(); + this->apple2.rept().clearKey(); } } if (sym == SDLK_F10) { - this->keyrepeater.release(); + this->apple2.rept().release(); } } diff --git a/src/emulator.h b/src/emulator.h index c3249bf..998c98b 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -36,7 +36,6 @@ class E2Config; class Emulator { PaddleButtonStates paddleButtonStates; KeypressQueue keypresses; - KeyRepeatHandler keyrepeater; KeyboardBufferMode buffered; ScreenImage screenImage;