-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove reliance on SFML from emulator classes
- Loading branch information
Showing
20 changed files
with
147 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
// | ||
// Created by doom on 19/03/24. | ||
// | ||
|
||
#ifndef SPEAKER_H | ||
#define SPEAKER_H | ||
|
||
#include <SFML/Audio.hpp> | ||
|
||
class Speaker { | ||
public: | ||
Speaker(); | ||
|
||
void play(); | ||
void stop(); | ||
private: | ||
sf::SoundBuffer soundBuffer; | ||
sf::Sound sound; | ||
virtual void play() = 0; | ||
virtual void stop() = 0; | ||
}; | ||
|
||
|
||
|
||
#endif //SPEAKER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target_sources(8ChocChip PRIVATE SfmlSpeaker.cpp | ||
SfmlSpeaker.h) | ||
|
||
add_subdirectory(ui) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "SfmlKeyboard.h" | ||
|
||
void SfmlKeyboard::handleKeyDown(uint8_t keyCode) { | ||
auto keyMapIter = this->KEYMAP.find(keyCode); | ||
if (keyMapIter != this->KEYMAP.end()) { | ||
uint8_t key = keyMapIter->second; | ||
this->keysPressed[key] = true; | ||
if (this->onNextKeyPress) { | ||
this->onNextKeyPress(key); | ||
this->onNextKeyPress = nullptr; | ||
} | ||
} | ||
} | ||
|
||
void SfmlKeyboard::handleKeyUp(uint8_t keyCode) { | ||
auto keyMapIter = this->KEYMAP.find(keyCode); | ||
if (keyMapIter != this->KEYMAP.end()) { | ||
uint8_t key = keyMapIter->second; | ||
this->keysPressed[key] = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef INC_8CHOCCHIP_SFMLKEYBOARD_H | ||
#define INC_8CHOCCHIP_SFMLKEYBOARD_H | ||
|
||
#include "../emulator/Keyboard.h" | ||
|
||
class SfmlKeyboard : public Keyboard { | ||
public: | ||
void handleKeyDown(uint8_t keyCode) override; | ||
void handleKeyUp(uint8_t keyCode) override; | ||
}; | ||
|
||
#endif // INC_8CHOCCHIP_SFMLKEYBOARD_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "SfmlRenderer.h" | ||
|
||
SfmlRenderer::SfmlRenderer(sf::RenderWindow* window) { | ||
this->window = window; | ||
|
||
this->scale = 15; // Scale up because 64 x 32 would be tiny on our screens now | ||
} | ||
|
||
void SfmlRenderer::drawPixel(uint16_t x, uint16_t y) { | ||
sf::RectangleShape rectangle(sf::Vector2f(getScale(), getScale())); | ||
rectangle.setPosition(x * getScale(), y * getScale()); | ||
rectangle.setFillColor(sf::Color::White); | ||
|
||
this->window->draw(rectangle); | ||
} | ||
|
||
uint8_t SfmlRenderer::getScale() const { | ||
return this->scale; | ||
} |
Oops, something went wrong.