mirror of
https://github.com/encounter/cpp3ds.git
synced 2026-03-30 11:04:22 -07:00
Delete some old input and screen code
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
#ifdef EMULATION
|
||||
#include <cpp3ds/Window/Input_sim_.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef CPP3DS_INPUT_HPP
|
||||
#define CPP3DS_INPUT_HPP
|
||||
|
||||
#define HID 0x10146000
|
||||
|
||||
#define SLIDERSTATE 0x10144000
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
enum Button {
|
||||
BUTTON_A = 1,
|
||||
BUTTON_B = 2,
|
||||
BUTTON_X = 1024,
|
||||
BUTTON_Y = 2048,
|
||||
BUTTON_UP = 64,
|
||||
BUTTON_DOWN = 128,
|
||||
BUTTON_LEFT = 32,
|
||||
BUTTON_RIGHT = 16,
|
||||
BUTTON_L1 = 512,
|
||||
BUTTON_R1 = 256,
|
||||
BUTTON_START = 8,
|
||||
BUTTON_SELECT = 4
|
||||
};
|
||||
|
||||
typedef void (*InputCallback)(Button button);
|
||||
|
||||
class Input {
|
||||
protected:
|
||||
int getHID();
|
||||
int last_hid;
|
||||
public:
|
||||
static float slider;
|
||||
static bool isDown(Button button);
|
||||
static void update(float deltaTime);
|
||||
static float get3DSlider(){ return Input::slider; }
|
||||
// int bind(Button button, Event event);
|
||||
// void unbind(int binding);
|
||||
// void unbindAll();
|
||||
// void unbindAll(Button button);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef CPP3DS_INPUT_HPP
|
||||
#define CPP3DS_INPUT_HPP
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
typedef sf::Keyboard::Key Button;
|
||||
|
||||
// enum Button {
|
||||
// BUTTON_A = 1,
|
||||
// BUTTON_B = 2,
|
||||
// BUTTON_X = 1024,
|
||||
// BUTTON_Y = 2048,
|
||||
const Button BUTTON_UP = sf::Keyboard::Up;
|
||||
const Button BUTTON_DOWN = sf::Keyboard::Down;
|
||||
const Button BUTTON_LEFT = sf::Keyboard::Left;
|
||||
const Button BUTTON_RIGHT = sf::Keyboard::Right;
|
||||
// BUTTON_L1 = 512,
|
||||
// BUTTON_R1 = 256,
|
||||
// BUTTON_START = 8,
|
||||
// BUTTON_SELECT = 4
|
||||
// };
|
||||
|
||||
typedef void (*InputCallback)(Button button);
|
||||
|
||||
class Input {
|
||||
protected:
|
||||
int getHID();
|
||||
int last_hid;
|
||||
public:
|
||||
static float slider;
|
||||
static bool isDown(Button button);
|
||||
static void update(float deltaTime);
|
||||
static float get3DSlider(){ return Input::slider; }
|
||||
// int bind(Button button, Event event);
|
||||
// void unbind(int binding);
|
||||
// void unbindAll();
|
||||
// void unbindAll(Button button);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <cpp3ds/Window/Input_.hpp>
|
||||
#include <cpp3ds/System/utils.hpp>
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
float Input::slider = 0;
|
||||
|
||||
int Input::getHID(){
|
||||
last_hid = read_word(HID);
|
||||
return last_hid;
|
||||
}
|
||||
|
||||
bool Input::isDown(Button button) {
|
||||
return (~read_word(HID) & button);
|
||||
}
|
||||
|
||||
void Input::update(float deltaTime){
|
||||
Input::slider = (float)(read_word(SLIDERSTATE) & 0xFF) / 255;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
#include <string.h>
|
||||
#include <cpp3ds/Window/Screen.hpp>
|
||||
#include <cpp3ds/Graphics/Color.hpp>
|
||||
#include <cpp3ds/Graphics/Drawable.hpp>
|
||||
#include <cpp3ds/System/utils.hpp>
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
void Screen::setPixelAddress(int addr, Color color){
|
||||
write_byte(addr, color.b);
|
||||
write_byte(addr+1, color.g);
|
||||
write_byte(addr+2, color.r);
|
||||
}
|
||||
|
||||
void Screen::setPixel(int x, int y, Color color){
|
||||
int addr = (720*x+720-(y*3)-3) + frame1;
|
||||
setPixelAddress(addr, color);
|
||||
addr = (720*x+720-(y*3)-3) + frame2;
|
||||
setPixelAddress(addr, color);
|
||||
}
|
||||
|
||||
void Screen::clear(Color color){
|
||||
if (color.r == color.g && color.g == color.b){
|
||||
memset((char*)frame1, color.r, width*height*3);
|
||||
memset((char*)frame2, color.r, width*height*3);
|
||||
} else {
|
||||
// TODO: Too slow, maybe try memcpy?
|
||||
char* frameptr1 = (char*)frame1;
|
||||
char* frameptr2 = (char*)frame2;
|
||||
for (int i = 0; i < width*height; ++i){
|
||||
*frameptr1++ = *frameptr2++ = color.b;
|
||||
*frameptr1++ = *frameptr2++ = color.g;
|
||||
*frameptr1++ = *frameptr2++ = color.r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::draw(Drawable& obj, float x, float y, bool use3D) {
|
||||
// TODO: Check bounds and don't draw objects outside screen
|
||||
obj.draw(*this, x, y, use3D, true);
|
||||
}
|
||||
|
||||
void Screen::_display(){
|
||||
buffer = !buffer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <cpp3ds/Emulator.hpp>
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
void display(){
|
||||
_emulator->screen->display();
|
||||
if (_emulator->getState() == EMU_PAUSED){
|
||||
_emulator->screen->setActive(false);
|
||||
_emulator->updatePausedFrame();
|
||||
while (_emulator->getState() == EMU_PAUSED)
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
}
|
||||
// _simulator->screen->renderWindow.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <cpp3ds/Emulator.hpp>
|
||||
#include <cpp3ds/Window/Input_.hpp>
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
float Input::slider = 0;
|
||||
|
||||
int Input::getHID(){
|
||||
// last_hid = read_word(HID);
|
||||
last_hid = 0;
|
||||
return last_hid;
|
||||
}
|
||||
|
||||
bool Input::isDown(sf::Keyboard::Key button) {
|
||||
// return (~read_word(HID) & button);
|
||||
return sf::Keyboard::isKeyPressed(button);
|
||||
}
|
||||
|
||||
void Input::update(float deltaTime){
|
||||
Input::slider = _emulator->get_slider3d();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
#include <string.h>
|
||||
#include <cpp3ds/Emulator.hpp>
|
||||
#include <cpp3ds/Graphics/Color.hpp>
|
||||
#include <cpp3ds/Graphics/Drawable.hpp>
|
||||
#include <cpp3ds/System/utils.hpp>
|
||||
//#include <cpp3ds/Window/Screen.hpp>
|
||||
/*
|
||||
namespace cpp3ds {
|
||||
|
||||
void Screen::setPixel(int x, int y, Color color){
|
||||
sf::Color c(color.r, color.g, color.b);
|
||||
pixelImage.setPixel(x, y, c);
|
||||
}
|
||||
|
||||
void Screen::clear(Color color){
|
||||
sf::RectangleShape box(sf::Vector2f(width, height));
|
||||
sf::Color c(color.r, color.g, color.b);
|
||||
sf::Color outline(25,25,25);
|
||||
box.setFillColor(c);
|
||||
box.setOutlineColor(outline);
|
||||
box.setOutlineThickness(EMU_OUTLINE_THICKNESS);
|
||||
box.setPosition(x,y);
|
||||
pixelImage.create(width, height, sf::Color::Transparent);
|
||||
// Should only clear the relevant screen area
|
||||
_emulator->screen->draw(box);
|
||||
}
|
||||
|
||||
void Screen::draw(cpp3ds::RenderTarget& target, cpp3ds::RenderStates states) {
|
||||
// void Screen::draw(Drawable& obj, float x, float y, bool use3D) {
|
||||
// TODO: Check bounds and don't draw objects outside screen
|
||||
// obj.draw(*this, x, y, use3D, true);
|
||||
Vertex* m_vertices = nullptr;
|
||||
target.draw(m_vertices, states);
|
||||
}
|
||||
|
||||
void Screen::_display() {
|
||||
sf::Texture starsTexture;
|
||||
starsTexture.loadFromImage(pixelImage);
|
||||
sf::Sprite test(starsTexture);
|
||||
test.setPosition(x, y);
|
||||
_emulator->screen->draw(test);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user