# Rewrite 5

- Move Libraries Source into pd directory and give them all their own CMakeLists.txt
- Partial rewrite core (color, autogenerated vec), lithium (now uses UNIQUE PTR for Commands), UI7
- Use MenuV2 as new standart in UI7
- Implementz ViewPort Pre alpha to UI7
- Add Line Drawing to DrawList (not Working)
- Implement a Complete new drievrs API (static Drivers)
- NO SUPPORT FOR SHARED LIBRARY BUILDS IN VERSION 5 YET
- Add Tools to Autogenerate Headers and Stuff
This commit is contained in:
2025-06-22 21:05:09 +02:00
parent 963fa72e41
commit 57634cbf4b
184 changed files with 13967 additions and 18453 deletions

32
backends/3ds/include/pd-3ds.hpp Executable file
View File

@ -0,0 +1,32 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd-3ds/bknd-gfx.hpp>
#include <pd-3ds/bknd-hid.hpp>
namespace PD {
void Init(void* data = nullptr);
}

View File

@ -22,15 +22,12 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
*/
#include <3ds.h>
#include <citro3d.h>
#include <pd/core/core.hpp>
#include <pd/lithium/backend.hpp>
#include <pd/lithium/lithium.hpp>
namespace PD {
template <typename T>
@ -43,30 +40,27 @@ class LinearAlloc : public Allocator<T> {
T* Allocate(size_t n) override { return (T*)linearAlloc(n * sizeof(T)); }
void Deallocate(T* ptr) { linearFree(ptr); }
};
namespace LI {
class Backend_C3D : public PD::LI::Backend {
namespace Li {
class GfxC3D : public GfxDriver {
public:
Backend_C3D() : LI::Backend("Citro3D") {}
~Backend_C3D() {}
PD_SMART_CTOR(Backend_C3D)
GfxC3D() : GfxDriver("Citro3D") {}
~GfxC3D() = default;
PD_SHARED(GfxC3D);
void Init() override;
void Deinit() override;
void NewFrame() override;
void BindTexture(PD::LI::TexAddress addr) override;
void RenderDrawData(const PD::Vec<PD::LI::Command::Ref>& Commands) override;
PD::LI::Texture::Ref LoadTexture(
void BindTex(PD::Li::TexAddress addr) override;
void RenderDrawData(
const std::vector<PD::Li::Command::Ref>& Commands) override;
PD::Li::Texture::Ref LoadTex(
const std::vector<PD::u8>& pixels, int w, int h,
PD::LI::Texture::Type type = PD::LI::Texture::Type::RGBA32,
PD::LI::Texture::Filter filter =
PD::LI::Texture::Filter::LINEAR) override;
PD::Li::Texture::Type type = PD::Li::Texture::Type::RGBA32,
PD::Li::Texture::Filter filter =
PD::Li::Texture::Filter::LINEAR) override;
private:
Vec<Vertex, LinearAlloc<Vertex>> VertexBuffer;
Vec<u16, LinearAlloc<u16>> IndexBuffer;
size_t CurrentVertex = 0;
@ -76,9 +70,9 @@ class Backend_C3D : public PD::LI::Backend {
DVLB_s* ShaderCode;
shaderProgram_s Shader;
C3D_AttrInfo ShaderInfo;
// For Stats
PD::u32 num_vtx = 0;
PD::u32 num_idx = 0;
// Stats oder so IDNK zu lange her
PD::u32 NumVtx;
PD::u32 NumIdx;
};
} // namespace LI
} // namespace Li
} // namespace PD

View File

@ -2,7 +2,8 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2025 tobid7
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -23,21 +24,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/hid_driver.hpp>
#include <pd/drivers/drivers.hpp>
namespace PD {
class Hid3DS : public Hid {
class Hid3DS : public HidDriver {
public:
/**
* Constructor to setup Key binds
*/
Hid3DS();
~Hid3DS() = default;
PD_SMART_CTOR(Hid3DS)
/**
* Overrideing the Update Function for Input Checking etc
*/
PD_SHARED(Hid3DS);
void Update() override;
};
} // namespace PD

View File

@ -1,117 +0,0 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <3ds.h>
#include <arpa/inet.h>
#include <malloc.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <pd/net/backend.hpp>
namespace PD {
class NetBackend3DS : public Net::Backend {
public:
NetBackend3DS() : Net::Backend("3DS") {}
~NetBackend3DS() = default;
PD_SMART_CTOR(NetBackend3DS)
bool Init() override {
pSocBuffer = (uint32_t*)memalign(pSocAlign, pSocBufferSize);
Result ret = 0;
if (pSocBuffer == NULL) {
return false;
}
if ((ret = socInit(pSocBuffer, pSocBufferSize)) != 0) {
return false;
}
return true;
}
void Deinit() override { socExit(); }
int NewSocket() override { return socket(AF_INET, SOCK_STREAM, 0); }
void Close(int sock_id) override { close(sock_id); }
int GetInvalidRef() const override { return -1; }
bool Bind(int sock_id, u16 port) {
sockaddr_in addr{};
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = INADDR_ANY;
return bind(sock_id, (sockaddr*)&addr, sizeof(addr)) != -1;
}
bool Listen(int sock_id, int backlog = 5) {
return listen(sock_id, backlog) != -1;
}
bool WaitForRead(int sock_id, int timeout_ms) override {
fd_set set;
FD_ZERO(&set);
FD_SET(sock_id, &set);
timeval timeout{};
timeout.tv_sec = timeout_ms / 1000;
timeout.tv_usec = (timeout_ms % 1000) * 1000;
int result = select(sock_id + 1, &set, nullptr, nullptr, &timeout);
return (result > 0 && FD_ISSET(sock_id, &set));
}
bool Accept(int sock_id, Net::Socket::Ref client) {
int client_soc = accept(sock_id, nullptr, nullptr);
if (client_soc == -1) {
return false;
}
client->pSocket = client_soc;
return true;
}
bool Connect(int sock_id, const std::string& ip, u16 port) {
sockaddr_in addr{};
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
inet_pton(AF_INET, ip.c_str(), &addr.sin_addr);
return connect(sock_id, (sockaddr*)&addr, sizeof(addr)) != -1;
}
int Send(int sock_id, const std::string& data) {
return send(sock_id, data.c_str(), static_cast<int>(data.size()), 0);
}
int Receive(int sock_id, std::string& data, int size = 1024) {
char* tmp = new char[size];
int res = recv(sock_id, tmp, size, 0);
if (res > 0) {
data.assign(tmp, res);
}
delete[] tmp;
return res;
}
private:
/** using libctru u32 here */
const uint32_t pSocAlign = 0x1000;
const uint32_t pSocBufferSize = 0x100000;
uint32_t* pSocBuffer = nullptr;
};
} // namespace PD