diff --git a/Doxyfile b/Doxyfile index 2ea6e0a..0ad1a4d 100644 --- a/Doxyfile +++ b/Doxyfile @@ -39,7 +39,7 @@ PROJECT_NAME = Renderd7-nightly # control system is used. -PROJECT_NUMBER = "v0.7.0" +PROJECT_NUMBER = "v0.9.3" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/Makefile b/Makefile index 517594b..8d2b420 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ include $(DEVKITARM)/3ds_rules export renderd7_MAJOR := 0 export renderd7_MINOR := 9 -export renderd7_PATCH := 1 +export renderd7_PATCH := 3 VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH) diff --git a/include/renderd7/BitmapPrinter.hpp b/include/renderd7/BitmapPrinter.hpp index 69cba0b..101afdc 100644 --- a/include/renderd7/BitmapPrinter.hpp +++ b/include/renderd7/BitmapPrinter.hpp @@ -13,60 +13,167 @@ #include namespace RenderD7 { +/// @brief Encoder enum Encoder { BITMAP, ///< Encode Data to Bitmap DIRECT, ///< Encode Direct to Framebuffer(No Decoder Required) C3D ///< Encode Directly to C3D_Tex (Just an Idea) }; +/// @brief Decoder enum Decoder { BITMAP2C3D, ///< Decode and Encode to C3D_Tex (Currently Fastest) (47,4ms) BITMAP2PNG2C3D ///< Decode Bitmap end Convert to Png, then C3D (Very Slow) ///< (201,4ms) }; +/// @brief BitmapPrinetr Class class BitmapPrinter { public: + /// @brief Constructor + /// @param w Widrth + /// @param h Height BitmapPrinter(int w, int h); + /// @brief Deconstructor ~BitmapPrinter(); + /// @brief Dexode Bitmap File + /// @param file path to File + /// @return success ? bool DecodeFile(std::string file); + /// @brief Set the Decoder + /// @param deccc Decoder void SetDecoder(Decoder deccc) { decc = deccc; } + /// @brief Draw a Pixel + /// @param x pos x + /// @param y pos y + /// @param b color blue + /// @param g color green + /// @param r color red + /// @param a color alpha void DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a); + /// @brief Draw Rectangle + /// @param x pos x + /// @param y pos y + /// @param w width + /// @param h height + /// @param line_w line width + /// @param b color blue + /// @param g color green + /// @param r color red + /// @param a colr alpha void DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a); + /// @brief Draw a Fillif Rectangle + /// @param x pos x + /// @param y pos y + /// @param w width + /// @param h height + /// @param b color blue + /// @param g color green + /// @param r color red + /// @param a color alpha void DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a); + /// @brief Draw Bitmap + /// @param x pos x + /// @param y pos y + /// @param map Bitmap to Print void DrawBitmap(int x, int y, BMP map); + /// @brief Use Prebuild Bitmap + /// @param map bitmap void UsePreMap(BMP map); + /// @brief Use Prebuild Printer Setup + /// @param printmap Printer void UsePrePrintMap(BitmapPrinter printmap); + /// @brief Get Bitmap + /// @return Bitmap BMP GetBitmap() { return bitmap; } + /// @brief Save to File + /// @param name Name/Path void SaveBmp(std::string name); + /// @brief Save as Png + /// @param name Name/Path void SavePng(std::string name); + /// @brief Setup Screen + /// @param target Screen void CreateScreen(C3D_RenderTarget *target); + /// @brief Draw Directly to Screen With Framerate + /// @param framerate Framerate + /// @return bool DrawScreenDirectF(int framerate); + /// @brief Draw Directly to Screen + /// @return bool DrawScreenDirect(); + /// @brief Render on Screen by Framerate + /// @param framerate Framerate void DrawScreenF(int framerate); + /// @brief Draw to Screen void DrawScreen(); + /// @brief Update Image by Framerate + /// @param framerate Framerate + /// @return bool UpdateScreenF(int framerate); + /// @brief Update Image + /// @return bool UpdateScreen(); + /// @brief Clear by Color + /// @param b color blue + /// @param g color green + /// @param r color red + /// @param a color alpha void Clear(u8 b = 0, u8 g = 0, u8 r = 0, u8 a = 255); + /// @brief Clear Completly Blank void ClearBlank(); + /// @brief Get Rendered Image + /// @return Image RenderD7::Image GetImage(); /// Test to Find out The Best Settings for BitmapPrinter void Benchmark(); - /// Setup the Benchmark + /// @brief Setup the Benchmark /// \param framerate The Fps of the ScreenUpdates void SetupBenchmark(int framerate); + /// @brief Check if Benchmark is Running + /// @return is running or not bool IsBenchmarkRunning() { return this->benchmark; } + /// @brief Draw a Dubug Text + /// @param x pos x + /// @param y pos y + /// @param t_size Size of the Text + /// @param color Color of the Text + /// @param text String of the Text void DrawDebugText(int x, int y, int t_size, u32 color, std::string text); + /// @brief Draw a Text width NFontApi (TTF) + /// @param x pos x + /// @param y pos y + /// @param t_size size of the Text + /// @param color Color of The Text + /// @param text String of The Text + /// @param font TTF Font void DrawText(int x, int y, float t_size, u32 color, std::string text, RenderD7::NFontApi font); private: // funcs + + /// @brief Decode 2 RenderD7::Image + /// @param deccc Decoder + /// @return bool Decode(Decoder deccc); + /// @brief Draw Char Func + /// @param posX pos x + /// @param posY pos y + /// @param t_size size + /// @param color color + /// @param character char void DrawDebugChar(u32 posX, u32 posY, int t_size, u32 color, char character); + /// @brief NFont Draw Char + /// @param posX pos x + /// @param posY pos y + /// @param t_size size + /// @param color color + /// @param character char + /// @param font ttf void DrawChar(int posX, int posY, float t_size, u32 color, char character, RenderD7::NFontApi font); // parameter diff --git a/include/renderd7/Draw.hpp b/include/renderd7/Draw.hpp index b642fd8..1af8f56 100644 --- a/include/renderd7/Draw.hpp +++ b/include/renderd7/Draw.hpp @@ -29,19 +29,82 @@ bool NFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1); /// @param color Color /// @return success ? bool Px(float x, float y, u32 color); +/// @brief Draw a Centered Text +/// @param x Pos X +/// @param y Pos Y +/// @param size Scale of the Text +/// @param color Color of The Text +/// @param Text Striing to Display +/// @param maxWidth Width to Calculate Centered Pos +/// @param maxHeight Height to Calculate Centered Pos +/// @param fnt Custom Font void TextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); +/// @brief Draw a Text +/// @param x Pos X +/// @param y Pos Y +/// @param size Scale of the Text +/// @param color Color of The Text +/// @param Text Striing to Display +/// @param maxWidth Width to Calculate Centered Pos +/// @param maxHeight Height to Calculate Centered Pos +/// @param fnt Custom Font void Text(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); +/// @brief Draw a Text Set to the Right +/// @param x Pos X +/// @param y Pos Y +/// @param size Scale of the Text +/// @param color Color of The Text +/// @param Text Striing to Display +/// @param maxWidth Width to Calculate Centered Pos +/// @param maxHeight Height to Calculate Centered Pos +/// @param fnt Custom Font void TextRight(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); +/// @brief Get Width of Text +/// @param size Size of the Text +/// @param Text String of The text +/// @param fnt Custom Font +/// @return The Size float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr); +/// @brief Get Text Size +/// @param size Size of The Text +/// @param width Width of the Text +/// @param height Height of The Text +/// @param Text String of Text +/// @param fnt Custom Font void GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt = nullptr); +/// @brief Get Height of the Text +/// @param size Size of the Text +/// @param Text String of the Text +/// @param fnt Custom Font +/// @return The Height float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr); +/// @brief Load A .bcfnt +/// @param fnt Output Font +/// @param Path path of The File +/// @return Result Code Result LoadFont(C2D_Font &fnt, const char *Path = ""); +/// @brief Unload a Font +/// @param fnt Font to Unload +/// @return Result Code Result UnloadFont(C2D_Font &fnt); +/// @brief Draw a Circle +/// @param x Pos X +/// @param y Pos Y +/// @param radius Radius of the Circle +/// @param color Color of the circle +/// @return success ? bool Circle(float x, float y, float radius, u32 color); +/// @brief Draw A Citro2D Image +/// @param img Image to Draw +/// @param x Pos X +/// @param y Pos Y +/// @param scaleX Scale of X-Axis +/// @param scaleY Scale of Y-Axis +/// @return success ? bool Image(C2D_Image img, float x, float y, float scaleX = 1.0f, float scaleY = 1.0f); } // namespace Draw diff --git a/include/renderd7/FileSystem.hpp b/include/renderd7/FileSystem.hpp index 9c725cd..fc485ea 100644 --- a/include/renderd7/FileSystem.hpp +++ b/include/renderd7/FileSystem.hpp @@ -6,12 +6,18 @@ namespace RenderD7 { namespace FileSystem { +/// @brief A Directory Entry struct Entry { + /// @brief Patf of The Entry std::string path; + /// @brief Name of The Entry std::string name; + /// @brief Directory or File bool dir = false; }; - +/// @brief Gets All Entrys of A Directory into a Vector +/// @param path The Path of the Directory +/// @return The Vector of found Entrys std::vector GetDirContent(std::string path); } // namespace FileSystem } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/Image.hpp b/include/renderd7/Image.hpp index cde4e9d..ead9d7b 100644 --- a/include/renderd7/Image.hpp +++ b/include/renderd7/Image.hpp @@ -16,9 +16,11 @@ namespace RenderD7 { /// Image Class class Image { public: + /// @brief Constructor Image() {} + /// @brief Deconstructor ~Image(); - + /// @brief Unload The Image void Unload(); /// Load Image from Png /// \param path path to png file diff --git a/include/renderd7/Ovl.hpp b/include/renderd7/Ovl.hpp index a5e8c4a..0d8237d 100644 --- a/include/renderd7/Ovl.hpp +++ b/include/renderd7/Ovl.hpp @@ -2,16 +2,26 @@ #include namespace RenderD7 { +/// @brief The Overlay Class (Used for Toasts for example) class Ovl { public: + /// @brief Deconstructor virtual ~Ovl() {} + /// @brief Function Called to Draw this virtual void Draw() const = 0; + /// @brief Logic of the Overlay virtual void Logic() = 0; + /// @brief Should the overlay be killed + /// @return Killed or Not inline bool IsKilled() { return this->iskilled; } + /// @brief Kill The Overlay inline void Kill() { iskilled = true; } private: + /// @param iskilled For IsKilled(); bool iskilled = false; }; +/// @brief Add an Overlay to the stack +/// @param scene Overlay to push to Stack void AddOvl(std::unique_ptr scene); } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/ResultDecoder.hpp b/include/renderd7/ResultDecoder.hpp index 3b3cd04..e2dd77e 100644 --- a/include/renderd7/ResultDecoder.hpp +++ b/include/renderd7/ResultDecoder.hpp @@ -3,23 +3,49 @@ #include namespace RenderD7 { +/// @brief Decoder for 3ds Result Codes class ResultDecoder { public: + /// @brief Constructor ResultDecoder() {} + /// @brief Deconstructor ~ResultDecoder() {} + /// @brief Load a Result into Decoder + /// @param rescode Result Code void Load(Result rescode); + /// @brief Load A Hex Converted Code into Decoder + /// @param rescode Result-Hex Code void Load(std::string rescode); + /// @brief Get Hex Code + /// @return Hex-Code std::string GetCode(); + /// @brief Get Level Name + /// @return Level Name std::string GetLevel(); + /// @brief Get Level Value + /// @return Level Value int GetLevelInt(); + /// @brief Get The Mosule Name + /// @return Module Name std::string GetModule(); + /// @brief Get The Module Value + /// @return Module Value int GetModuleInt(); + /// @brief Get The Description + /// @return Description std::string GetDescription(); + /// @brief Get The Description Valur + /// @return Description Value int GetDescriptionInt(); + /// @brief Get the Summary + /// @return Summary std::string GetSummary(); + /// @brief Get the Summary Value + /// @return Summary Value int GetSummaryInt(); private: + /// @param m_rescode Result code Result m_rescode; }; } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/Screen.hpp b/include/renderd7/Screen.hpp index 9efb573..a7e8147 100644 --- a/include/renderd7/Screen.hpp +++ b/include/renderd7/Screen.hpp @@ -2,12 +2,15 @@ #include #include +/// \param Top Tob-Screen Target extern C3D_RenderTarget *Top; +/// \param TopRight Top-Right-Screen Target (Never atually used) extern C3D_RenderTarget *TopRight; +/// \param Bottom Bottom-Screen Target extern C3D_RenderTarget *Bottom; namespace RenderD7 { -/// Set current RenderScreen -/// \param target The RenderTarget Top, Bottom +/// @brief Begin Drawing On Specific Screen +/// @param target The Screen Target (Top, Bottom or TopTight) void OnScreen(C3D_RenderTarget *target); } // namespace RenderD7 diff --git a/include/renderd7/Sheet.hpp b/include/renderd7/Sheet.hpp index ff20fa3..86d3564 100644 --- a/include/renderd7/Sheet.hpp +++ b/include/renderd7/Sheet.hpp @@ -3,19 +3,20 @@ #include namespace RenderD7 { -/** The Spritesheet Class */ +/// @brief SpriteSheet Class class Sheet { public: - /// Construct sheet + /// @brief Constructor Sheet(); - // Deconstruct sheet + /// @brief Deconstructor ~Sheet(); - /// Load a Sritesheet - /// \param path Path to the Spritesheet (.t3x) + /// @brief Load A Spritesheet File + /// @param path Path to the t3x + /// @return Result Code Result Load(const char *path); - /// Unload the Spritesheet + /// @brief Unload the Sheet void Free(); - /// The Spritesheet + /// \param spritesheet The Sheet C2D_SpriteSheet spritesheet; }; } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/Sprite.hpp b/include/renderd7/Sprite.hpp index 3832188..a7542be 100644 --- a/include/renderd7/Sprite.hpp +++ b/include/renderd7/Sprite.hpp @@ -7,7 +7,7 @@ #include namespace RenderD7 { -/// Sprite Class +/// @brief Sprite Class class Sprite { public: /// \brief Construct Sprite @@ -21,19 +21,44 @@ public: /// \brief Load a Sprite From SpriteSheet /// \param img the Image to load from.(RenderD7::Image) void FromImage(RenderD7::Image *img); + /// @brief Draw the Sprite + /// @return success ? bool Draw(); + /// @brief Set the Center Position + /// @param x X Pos + /// @param y Y Pos void SetCenter(float x, float y); + /// @brief Set the Sprite's Position + /// @param x X Pos + /// @param y Y Pos void SetPos(float x, float y); + /// @brief Set The Sprite's Scale + /// @param x Scale on X-Axis + /// @param y Scale on Y-Axis void SetScale(float x, float y); + /// @brief Set the Sprite's Rotation + /// @param rotation ratation void SetRotation(float rotation); + /// @brief Rotate the Sprite + /// @param speed Speed to Rotate void Rotate(float speed); + /// @brief Get Tje Sprite's Width + /// @return Width float getWidth(); - float getHeigh(); + /// @brief Get the Sprite's Height + /// @return Height + float getHeight(); + /// @brief Get The Sprite's X Position + /// @return X Position float getPosX(); + /// @brief Get the Sprite's Y Position + /// @return Y Position float getPosY(); private: + /// @param tint ImageTint (unused) C2D_ImageTint tint; + /// @param sprite The Sprite C2D_Sprite sprite; }; } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/SpriteAnimation.hpp b/include/renderd7/SpriteAnimation.hpp index 0f0679d..0236060 100644 --- a/include/renderd7/SpriteAnimation.hpp +++ b/include/renderd7/SpriteAnimation.hpp @@ -7,19 +7,35 @@ #include namespace RenderD7 { +/// @brief SpriteSheetAnimation Class class SpriteSheetAnimation : public RenderD7::Sprite { public: + /// @brief Constructor SpriteSheetAnimation(); + /// @brief Deconstructor ~SpriteSheetAnimation(); + /// @brief Setup an Animation + /// @param sheet Input Spritesheet + /// @param imagecount Count of Images + /// @param startimage Where to Start the Loop + /// @param frame_begin Current Time (Should be 0) + /// @param frame_finish Time Length void Setup(RenderD7::Sheet *sheet, size_t imagecount, size_t startimage, float frame_begin, float frame_finish); + /// @brief Play the Animation + /// @param timespeed Speed of the animation void Play(float timespeed); private: + /// @param images Count of Images size_t images; + /// @param imgs Another Count of images ??? size_t imgs = 0; + /// @param D_totaltime Current Time float D_totaltime; + /// @param sheet The Sheet of Images RenderD7::Sheet *sheet; + /// @param time Total Time from frame_finish float time; }; } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/StealConsole.hpp b/include/renderd7/StealConsole.hpp index a14a869..29a5da6 100644 --- a/include/renderd7/StealConsole.hpp +++ b/include/renderd7/StealConsole.hpp @@ -3,13 +3,19 @@ #include namespace RenderD7 { +/// @brief StealConsole Class class StealConsole { public: + /// @brief Constructor StealConsole(); + /// @brief Deconstructor ~StealConsole(); + /// @brief The Stolen Stdout + /// @return Stdout as string std::string GetStdout(); private: + /// @param stolen_stdout Stolen Stdout std::stringstream stolen_stdout; }; } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/Tasks.hpp b/include/renderd7/Tasks.hpp index f3d918a..242a206 100644 --- a/include/renderd7/Tasks.hpp +++ b/include/renderd7/Tasks.hpp @@ -2,7 +2,12 @@ #include <3ds.h> #include +namespace RenderD7 { namespace Tasks { +/// @brief Push A Task +/// @param entrypoint Function of Your Task void create(ThreadFunc entrypoint); +/// @brief Destroy all Tasks void destroy(void); -} // namespace Tasks \ No newline at end of file +} // namespace Tasks +} // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/Time.hpp b/include/renderd7/Time.hpp index 194825f..58e6fb5 100644 --- a/include/renderd7/Time.hpp +++ b/include/renderd7/Time.hpp @@ -2,6 +2,12 @@ #include namespace RenderD7 { +/// @brief Format a String +/// @param fmt_str Format To +/// @param ... Additional Args +/// @return Formatted String std::string FormatString(std::string fmt_str, ...); +/// @brief Get Current Time as String +/// @return Time-String std::string GetTimeStr(void); } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/Toast.hpp b/include/renderd7/Toast.hpp index 2d208da..7130d18 100644 --- a/include/renderd7/Toast.hpp +++ b/include/renderd7/Toast.hpp @@ -6,17 +6,25 @@ #include namespace RenderD7 { +/// @brief Toast Class class Toast : public RenderD7::Ovl { public: + /// @brief Constructor + /// @param head Displayed String in Head + /// @param msg Displayed String in Message Box Toast(std::string head, std::string msg); + /// @brief Override for Draw void Draw(void) const override; + /// @brief Override for Logic void Logic() override; private: - RenderD7::BitmapPrinter toast = RenderD7::BitmapPrinter(400, 70); - RenderD7::Image *toastrendered; + /// @param head The Header Text + /// @param nsg The Message-Box Text std::string head, msg; + /// @param msgposy Position Y of The Toast int msgposy = 240; + /// @param delay Delay of the Toast int delay = 0; }; } // namespace RenderD7 \ No newline at end of file diff --git a/include/renderd7/bmpconverter.hpp b/include/renderd7/bmpconverter.hpp index d2fa822..37c3529 100644 --- a/include/renderd7/bmpconverter.hpp +++ b/include/renderd7/bmpconverter.hpp @@ -4,9 +4,9 @@ #include namespace BitmapConverter { -// returns 0 if all went ok, non-0 if error -// output image is always given in RGBA (with alpha channel), even if it's a BMP -// without alpha channel +/// returns 0 if all went ok, non-0 if error +/// output image is always given in RGBA (with alpha channel), even if it's a +/// BMP without alpha channel unsigned decodeBMP(std::vector &image, unsigned &w, unsigned &h, const std::vector &bmp); diff --git a/include/renderd7/external/nvid.hpp b/include/renderd7/external/nvid.hpp index 0355d7d..0e1f591 100644 --- a/include/renderd7/external/nvid.hpp +++ b/include/renderd7/external/nvid.hpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -59,37 +60,6 @@ inline bool CheckFrame(NVID_Frame &frame) { return false; } -/*inline std::vector LoadNVID(std::string path) { - std::vector res; - NVID_Header t_header; - std::ifstream nvid_file2("out.nvid", std::ios::binary | std::ios::in); - - nvid_file2.read((char *)&t_header, sizeof(NVID_Header)); - if (!CheckHeader(t_header)) - return res; - - for (int i = 0; i < t_header.framecount; i++) { - NVID_Image tmp; - NVID_Frame frm; - nvid_file2.read((char *)&frm, sizeof(NVID_Frame)); - if (!CheckFrame(frm)) { - return res; - } - void *pBuf = malloc(frm.framesize); - nvid_file2.read((char *)pBuf, frm.framesize); - int lw, lh, lc; - unsigned char *dat_s = jpgd::decompress_jpeg_image_from_memory( - (unsigned char *)pBuf, frm.framesize, &lw, &lh, &lc, 3); - tmp.bpp = lc; - tmp.w = lw; - tmp.h = lh; - tmp.framenum = i; - tmp.pBuf = dat_s; - res.push_back(tmp); - } - return res; -}*/ - inline std::vector> LoadNVID(const std::string &path) { std::vector> res; @@ -182,72 +152,71 @@ inline std::vector> LoadMemNVID(const void *data, class NVID_Stream { public: - NVID_Stream() {} - ~NVID_Stream() {} + NVID_Stream(const std::string &path) + : file_(path, std::ios::binary | std::ios::in) { + if (!file_) { + std::cout << "Failed to open NVID file: " << path << std::endl; + return; + } else { + file_.read(reinterpret_cast(&header_), sizeof(header_)); + if (!CheckHeader(header_)) { + std::cout << "Invalid NVID header" << std::endl; + return; + } + } + } - bool Load(const std::string &path) { - file.open(path, std::ios::in | std::ios::binary); - if (!file) { - std::cerr << "Error: failed to open " << path << std::endl; + NVID_Stream(const void *data, std::size_t size) { + if (!data || size < sizeof(header_)) { + std::cout << "Invalid NVID data" << std::endl; + return; + } else { + memcpy(&header_, data, sizeof(header_)); + if (!CheckHeader(header_)) { + std::cout << "Invalid NVID header" << std::endl; + return; + } + } + } + + ~NVID_Stream() { file_.close(); } + + bool ReadNext(NVID_Image &image) { + if (!file_) { return false; } - file.read(reinterpret_cast(&t_header), sizeof(NVID_Header)); - if (!CheckHeader(t_header)) { - std::cerr << "Error: invalid NVID file header" << std::endl; + + NVID_Frame frame; + file_.read(reinterpret_cast(&frame), sizeof(frame)); + if (!CheckFrame(frame)) { + std::cout << "Invalid NVID frame" << std::endl; return false; } - currentreg = 0; + + std::vector compressed_data(frame.framesize); + file_.read(reinterpret_cast(compressed_data.data()), + compressed_data.size()); + + int width, height, components; + unsigned char *decompressed_data = jpgd::decompress_jpeg_image_from_memory( + compressed_data.data(), compressed_data.size(), &width, &height, + &components, 3); + if (!decompressed_data) { + std::cout << "Failed to decompress JPEG data" << std::endl; + return false; + } + + image.bpp = components; + image.w = width; + image.h = height; + image.framenum = current_frame_++; + image.pBuf = decompressed_data; + return true; } - void Update() { - if (!file) { - return; - } - NVID_Frame frm; - file.read(reinterpret_cast(&frm), sizeof(NVID_Frame)); - if (!CheckFrame(frm)) { - return; - } - if (frm.framesize > buffer.size()) { - buffer.resize(frm.framesize); - } - file.read(reinterpret_cast(buffer.data()), frm.framesize); - int lw, lh, lc; - unsigned char *dat_s = jpgd::decompress_jpeg_image_from_memory( - buffer.data(), frm.framesize, &lw, &lh, &lc, 3); - if (!dat_s) { - std::cerr << "Error: failed to decompress JPEG data" << std::endl; - return; - } - current_frame.bpp = lc; - current_frame.w = lw; - current_frame.h = lh; - current_frame.framenum = currentreg; - current_frame.pBuf = dat_s; - currentreg++; - if (currentreg > (int)t_header.framecount) { - file.seekg(sizeof(NVID_Header)); - currentreg = 0; - } - } - - NVID_Image GetImage() const { return current_frame; } - private: - bool CheckHeader(const NVID_Header &header) const { - // TODO: implement header validation logic - return true; - } - - bool CheckFrame(const NVID_Frame &frame) const { - // TODO: implement frame validation logic - return true; - } - - NVID_Image current_frame; - NVID_Header t_header; - int currentreg = 0; - std::ifstream file; - std::vector buffer; -}; + std::ifstream file_; + NVID_Header header_; + int current_frame_ = 0; +}; \ No newline at end of file diff --git a/include/renderd7/lang.hpp b/include/renderd7/lang.hpp index f114ff9..39ada2b 100644 --- a/include/renderd7/lang.hpp +++ b/include/renderd7/lang.hpp @@ -2,14 +2,17 @@ #include #include -/// RenderD7::Lang -namespace RenderD7::Lang { -/// Get the 3ds System Language +namespace RenderD7 { +namespace Lang { +/// @brief Get 3ds System lang! [en] by default +/// @return Sytemlang as string std::string getSys(); -/// Get a translated string -/// \param key The Key so the code can find your string +/// @brief Get The Translation String +/// @param key Key of Translation +/// @return The Translated String std::string get(const std::string &key); -/// Load the lang file from dir structure en/app.json for sample -/// \param lang the folder name en, fr, de ... . I prefer geSys() +/// @brief Load A Language json +/// @param lang The Language Key [en], [de], etc, or getSys() void load(const std::string &lang); -} // namespace RenderD7::Lang +} // namespace Lang +} // namespace RenderD7 diff --git a/include/renderd7/log.hpp b/include/renderd7/log.hpp index e43c5e1..9f9b535 100644 --- a/include/renderd7/log.hpp +++ b/include/renderd7/log.hpp @@ -5,23 +5,26 @@ #include #include -/** Log Class */ +/// @brief Log Class class Log { public: - /** Construct */ + /// @brief Constructor Log(); - /** Deconstruct */ + /// @brief Deconstructor ~Log(); - /// Init the log file - /// \param filename name for the file + /// @brief Init the Logger + /// @param filename Filename[_data_time.log] void Init(const char *filename); - /// Write Text to logfile - /// \param debug_text your text + /// @brief Write a String to the File + /// @param debug_text string void Write(std::string debug_text); - /// Get the date + /// @brief Get the Date + /// @return Date as string fmt[data_time] std::string logDate(void); - /// Format to logstyle - /// \param fmt_str the formatted style + /// @brief Format a string like sprintf + /// @param fmt_str the string wich defines the fmt + /// @param ... Additional Data + /// @return Formatted String std::string format(const std::string &fmt_str, ...); private: diff --git a/include/renderd7/renderd7.hpp b/include/renderd7/renderd7.hpp index 82c42b1..a086ba0 100644 --- a/include/renderd7/renderd7.hpp +++ b/include/renderd7/renderd7.hpp @@ -44,16 +44,20 @@ #include #include -#define RENDERD7VSTRING "0.9.2" +#define RENDERD7VSTRING "0.9.3" #define CHANGELOG \ - "0.9.2: Add NpiSplashVideo\nNvid Support(v0.0.1)\nAdd Basic RenderD7 " \ + "0.9.3: Completly Documanted Everything\nFix typo in " \ + "Sprite::getHeight()\nRemove Deprecated/Useless Stuff\n0.9.2: Add " \ + "NpiSplashVideo\nNvid Support(v0.0.1)\nAdd " \ + "Basic RenderD7 " \ "Splash\nFaster Graphics Init\nFade Effects\nFix Screen for this " \ - "Changelog\n0.9.1: Fix Critical bug in\nSpritesheet animations\nFix Color " \ + "Changelog\n0.9.1: Fix Critical bug in\nSpritesheet animations\nFix " \ + "Color " \ "Conver(Hex)\n0.9.0: Remove Stupid try of Console\nAdd Services list and " \ "Clean up " \ "Code.\nAlso added Minimal Init for hax2.x\n0.8.5: Fix Deltatime \n0.8.4: " \ "A lot of Fixes and new\nFeatures for BitmapPrinter! \n0.8.3: Addet " \ - "Overlaycount to Info\nand Addet ResultDecoder for errors.\n\n0.8.2: Fix a " \ + "Overlaycount to Info\nand Addet ResultDecoder for errors.\n0.8.2: Fix a " \ "lot of Stuff and\nadd c++17 based filesystem class.\n0.8.1: Add abillity " \ "to Get Stdout as string\nto render it to the screen.\n0.8.0: Implement " \ "BitmapPrinter\n0.7.3: Implement Over\nRender Overlay Framework\n0.7.2: " \ @@ -72,104 +76,172 @@ "Release of\nD7-Core sprite animation plugin!" #define DEFAULT_CENTER 0.5f -/*extern C3D_RenderTarget* Top; -extern C3D_RenderTarget* TopRight; -extern C3D_RenderTarget* Bottom;*/ - +/// @param d7_hDown Current Key Down extern u32 d7_hDown; +/// @param d7_hHeld Current Key Held extern u32 d7_hHeld; +/// @param d7_hUp Current Key Up extern u32 d7_hUp; +/// @param d7_touch Current Touch Position extern touchPosition d7_touch; +/// @param dspststus Dsp Status String extern std::string dspststus; +/// @param rd7_do_splash Config Value To Enable RenderD7 Splash extern bool rd7_do_splash; /// RenderD7 namespace RenderD7 { +/// @brief Get Deltatime +/// @return Deltatime float GetDeltaTime(); -enum kbd { SWKBD, BKBD }; -enum kbd_type { NUMPAD, STANDARD }; -struct TObject { - int x; // Position X - int y; // Position Y - int w; // Button Width - int h; // Button Height - std::string text = ""; // Text - float correctx = 0; // Correct X Position - float correcty = 0; // Correct Y Position - float txtsize = 0.7f; // Set Text Size +/// @brief Keyboard +enum kbd { + /// @brief libctru Keyboard + SWKBD, + /// @brief Unk (Not Usable) + BKBD }; - +/// @brief Keyboar Type +enum kbd_type { NUMPAD, STANDARD }; +/// @brief A Button +struct TObject { + int x; ///< Position X + int y; ///< Position Y + int w; ///< Button Width + int h; ///< Button Height + std::string text = ""; ///< Text + float correctx = 0; ///< Correct X Position + float correcty = 0; ///< Correct Y Position + float txtsize = 0.7f; ///< Set Text Size +}; +/// @brief Scene Class class Scene { public: + /// @brief Stack of the Scenes static std::stack> scenes; + /// @brief Deconstructor virtual ~Scene() {} + /// @brief Logic To Overide + /// @param hDown Key Down + /// @param hHeld Key Held + /// @param hUp Key Up + /// @param touch Touch Position virtual void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) = 0; + /// @brief Draw Func to Override virtual void Draw() const = 0; - // virtual void Ovl() const = 0; + /// @brief Push a Scene to Stack + /// @param scene Scene to Push + /// @param fade FadeEffect (Not Correctly Implementet yet) static void Load(std::unique_ptr scene, bool fade = false); + /// @brief Go Back a Scene static void Back(); + /// @brief do the Draw (Called in RenderD7::MainLoop()) static void doDraw(); + /// @brief do the Logic (Called in RenderD7::MainLoop()) + /// @param hDown Key Down + /// @param hHeld Key Held + /// @param hUp Key Up + /// @param touch Touch Positon static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch); - // static void HandleOvl(); }; +/// @brief Integrated Setting Menu of RenderD7 class RSettings : public RenderD7::Scene { private: + /// @brief Calculate the Changelog Screen Stuff + /// @param lines vector of Lines + /// @param screen_index Current Screen + /// @param screens Count of Possible Screens void calculate_screens(const std::vector &lines, int &screen_index, int &screens); - + /// @brief State (Define for Menus) enum RState { RSETTINGS, RINFO, RSERVICES, RCLOG }; + /// @param m_state Current menu State (Default=MainMenu aka RSETTINGS) RenderD7::RSettings::RState m_state = RenderD7::RSettings::RState::RSETTINGS; - mutable float txtposy = 30; + /// @param screens Count of Changelog Screens int screens = 0; + /// @param screen_index Current Changelog Screen int screen_index = 0; + /// @param lines Vector of Changelog-Lines std::vector lines; + /// @param rd7srstate State of RenderD7 Super Reselution std::string rd7srstate = "false"; + /// @param mtovlstate State of Metricks Overlay std::string mtovlstate = "false"; + /// @param fpsstate Value of Forced Framerate std::string fpsstate = "60"; + /// @param mtscreenstate Screen the Overlay is Set to std::string mtscreenstate = "Top"; - std::string mttxtcolstate = "#ffffff"; - std::string mtcola = "255"; - std::string mttxtcola = "255"; + /// @param buttons Vector of Buttons std::vector buttons = { - {20, 35, 120, 35, "RD7SR", -11, 10}, - {20, 85, 120, 35, "Changelog", -27, 9}, - {20, 135, 120, 35, "MT_OVL", -19, 10}, - {20, 185, 120, 35, "FPS", 6, 10}, - {180, 35, 120, 35, "MTSCREEN", -29, 10}, - {180, 85, 120, 35, "DSPERR", -13, 10}, + {20, 35, 120, 35, "RD7SR", -8, 10}, + {20, 85, 120, 35, "Changelog", -24, 11}, + {20, 135, 120, 35, "Metrik-Ovl", -23, 10}, + {20, 185, 120, 35, "NOTYET", -13, 10}, + {180, 35, 120, 35, "MTSCREEN", -27, 10}, + {180, 85, 120, 35, "NOTYET", -13, 10}, {180, 135, 120, 35, "INFO", 2, 10}, {180, 185, 120, 35, "Services", -13, 10}}; public: + /// @brief Constructor RSettings(); + /// @brief Override for Draw + /// @param void Draw(void) const override; + /// @brief Deconstructor ~RSettings(); + /// @brief Override for Logic + /// @param hDown Key Down + /// @param hHeld Key Held + /// @param hUp Key Up + /// @param touch Touch Position void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) override; }; +/// @brief Show Up the RenderD7-Settings Menu void LoadSettings(); +/// @brief DspNotFound Error Toast (Deprectated) class DSP_NF : public RenderD7::Ovl { public: + /// @brief Constructor DSP_NF(); + /// @brief Override for Draw void Draw(void) const override; + /// @brief Override for Logic void Logic() override; private: + /// @param msgposy Y Position of Toast int msgposy = 240; + /// @param delay Delay of Toast int delay = 0; }; +/// @brief Get A Rendom Int +/// @param b From +/// @param e To +/// @return Random Int int GetRandomInt(int b, int e); +/// @brief DrawMetrikOvl (YOUR OWN RISK) void DrawMetrikOvl(); +/// @brief Draw Image from RenderD7 Sheet +/// @param sheet Spritesheet +/// @param index Image index Value +/// @param x Pos X +/// @param y Pos Y +/// @param scaleX Scale on X-Axis +/// @param scaleY Scale on Y-Axis +/// @return success ? bool DrawImageFromSheet(RenderD7::Sheet *sheet, size_t index, float x, float y, float scaleX = 1.0, float scaleY = 1.0); +/// @brief Display the Npi-D7 Video Intro (NVID) void DoNpiIntro(); /// @brief Fade In /// @param duration Duration in Frames @@ -177,112 +249,182 @@ void FadeIn(); /// @brief Fade Out /// @param duration Duration in Frames void FadeOut(); +/// @brief Display Fade Effects void FadeDisplay(); + namespace Error { +/// @brief DEPRECATED Display Error for n Seconds +/// @param toptext Head Text +/// @param errortext Error Text +/// @param timesec Time n to Display in Seconds void DisplayError(std::string toptext, std::string errortext, int timesec = 3); +/// @brief Display A Fatal Error +/// @param toptext Head Text +/// @param errortext Error Text void DisplayFatalError(std::string toptext, std::string errortext); } // namespace Error + namespace Init { +/// @brief Init Default RenderD7 +/// @param app_name Name of Your App +/// @return ResCode Result Main(std::string app_name = "RD7Game"); +/// @brief Init Minimal RenderD7 (For better Hax2.x support) +/// @param app_name Name of Your App +/// @return ResCode Result Minimal(std::string app_name = "RD7Game"); +/// @brief Reload the Graphics Engine +/// @return ResCode Result Reload(); +/// @brief Init Graphics Only (NOT SUPPORTET use Reload) void Graphics(); +/// @brief Init Ndsp for Sounds void NdspFirm(); } // namespace Init + namespace Exit { +/// @brief Exit Default RenderD7 void Main(); +/// @brief Exit Minimal RenderD7 void Minimal(); +/// @brief Exit Ndsp void NdspFirm(); +/// @brief DEPRECATED Exit Graphics void Graphics(); } // namespace Exit + namespace Msg { +/// @brief Display A Message +/// @param titletxt Header Text +/// @param subtext Message Text +/// @param target Screen void Display(std::string titletxt, std::string subtext, C3D_RenderTarget *target); +/// @brief Display A Message Wit Progress +/// @param titletext Header Text +/// @param subtext Message Text +/// @param current Current Progress +/// @param total Total Progress +/// @param prgbarcolor Color of Progressbar void DisplayWithProgress(std::string titletext, std::string subtext, float current, float total, u32 prgbarcolor); } // namespace Msg namespace Convert { +/// @brief Convert a String to Flaot +/// @param inp Input String +/// @return Float inline float StringtoFloat(std::string inp) { return std::atof(inp.c_str()); } +/// @brief Convert String to Int +/// @param inp Input String +/// @return Int inline int StringtoInt(std::string inp) { return std::atoi(inp.c_str()); } -inline bool FloatToBool(float inp) { - if (inp == 1) - return true; - else - return false; -} +/// @brief Convert a Float to Bool +/// @param inp Input Float +/// @return Bool +inline bool FloatToBool(float inp) { return (inp == 1 ? true : false); } } // namespace Convert +/// @brief DEPRECATED DirContent struct DirContent { - std::string name; - std::string path; - bool isDir; + std::string name; ///< Content Name + std::string path; ///< Content Path + bool isDir; ///< Is Directory }; namespace FS { +/// @brief Check if File exists +/// @param path Path to the File +/// @return exists or not bool FileExist(const std::string &path); -} +} // namespace FS +/// @brief Check if Ndsp is Init +/// @return is or not bool IsNdspInit(); +/// @brief Setup RenderD7 Logs void SetupLog(void); +/// @brief Get Current Framerate as String +/// @return Framerate String std::string GetFramerate(); +/// @brief MainLoop of RenderD7s +/// @return Is Still Running or not bool MainLoop(); +/// @brief Exit App (brak the MainLoop) void ExitApp(); +/// @brief Clear the Citro2D TextBuffers +/// @param void ClearTextBufs(void); +/// @brief Open A Keyboard (SWKBD) +/// @param lenght Length of the string +/// @param tp Type of The Keyboard +/// @return the string if pressed Ok std::string Kbd(int lenght, SwkbdType tp); +/// @brief Draw Overlays And end the Frame. DO NEVER USE C3D_FRAMEEND cause it +/// breaks Overlay crash Security void FrameEnd(); +/// @brief Enable/Disable RenderD7 Super Reselution void ToggleRD7SR(); +/// @brief Check if RD7SR is Enabled +/// @return is or not bool IsRD7SR(); +/// @brief Textless Button struct TLBtn { - int x; // Position X - int y; // Position Y - int w; // Button Width - int h; // Button Height + int x; ///< Position X + int y; ///< Position Y + int w; ///< Button Width + int h; ///< Button Height }; - -struct ScrollList1 { - std::string Text = ""; -}; - -struct ScrollList2 { - float x; - float y; - float w; - float h; - std::string Text = ""; -}; -/*enum ListType -{ - ONE, - TWO -};*/ -void DrawList1(RenderD7::ScrollList1 &l, float txtsize, C3D_RenderTarget *t); +/// @brief Draw Buttons +/// @param tobjects Vector of Buttons +/// @param color Color of the Buttons +/// @param txtcolor Color of The Text +/// @param selection Positon of Selection +/// @param selbgcolor Selection BackgroundColor +/// @param selcolor Selection Color void DrawTObjects(std::vector tobjects, u32 color, u32 txtcolor, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000")); +/// @brief Draw A Single Button +/// @param tobject Button +/// @param tobjectindex Button Index +/// @param color Color of the Button +/// @param txtcolor Color of The Text void DrawSTObject(std::vector tobject, int tobjectindex, u32 color, u32 txtcolor); +/// @brief Touched A Button +/// @param touch Touch Position +/// @param button Button +/// @return is touched or not bool touchTObj(touchPosition touch, RenderD7::TObject button); +/// @brief Touched A Textless Button +/// @param touch Touch Position +/// @param button Button +/// @return is touched or not bool touchTLBtn(touchPosition touch, RenderD7::TLBtn button); +/// @brief Draw Textless Buttons +/// @param tobjects Vector of Buttons +/// @param color Color of the Buttons +/// @param selection Positon of Selection +/// @param selbgcolor Selection BackgroundColor +/// @param selcolor Selection Color void DrawTLBtns(std::vector btns, u32 color, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000")); -struct Checkbox { - float x, y, s; - bool is_chexked = false; - u32 outcol, incol, chcol; -}; -void DrawCheckbox(Checkbox box); - +/// @brief DEPRECATED USE RenderD7::FileSystem +/// @param dircontent Vector of Content output +/// @param extensions Extensions void GetDirContentsExt(std::vector &dircontent, const std::vector &extensions); +/// @brief DEPRECATED USE RenderD7::FileSystem +/// @param dircontent Vector of Content output void GetDirContents(std::vector &dircontent); } // namespace RenderD7 diff --git a/include/renderd7/sound.hpp b/include/renderd7/sound.hpp index 1cf852b..340a48c 100644 --- a/include/renderd7/sound.hpp +++ b/include/renderd7/sound.hpp @@ -11,17 +11,20 @@ public: /// \param channel the channel 1-23 /// \param toloop true:loop the sound, false: don't loop sound(const std::string &path, int channel = 1, bool toloop = false); - /** deconstruct the sound */ + /// @brief Deconstructor ~sound(); - /** play the sound */ + /// @brief Play the sound void play(); - /** stop the sound */ + /// @brief Stop the sound void stop(); private: - /// \param dataSize the Size of the filedata + /// \param dataSize Size of the filedata u32 dataSize; + /// \param waveBuf For ndsp ndspWaveBuf waveBuf; - u8 *data = NULL; + /// \param data Memmory data of the sound + uint8_t *data = NULL; + /// \param chnl Channel of the sound int chnl; }; diff --git a/include/renderd7/stringtool.hpp b/include/renderd7/stringtool.hpp index 961a62d..d027041 100644 --- a/include/renderd7/stringtool.hpp +++ b/include/renderd7/stringtool.hpp @@ -4,6 +4,10 @@ #include namespace RenderD7 { +/// @brief Check if A String ends with +/// @param name Input String +/// @param extensions Extensions to Check for +/// @return Ends with or not inline bool NameIsEndingWith(const std::string &name, const std::vector &extensions) { if (name.substr(0, 2) == "._") @@ -24,6 +28,7 @@ inline bool NameIsEndingWith(const std::string &name, return false; } } // namespace RenderD7 + template T GetFileName(T const &path, T const &delims = "/\\") { return path.substr(path.find_last_of(delims) + 1); } diff --git a/include/renderd7/thread.hpp b/include/renderd7/thread.hpp index ffb79da..f75c64f 100644 --- a/include/renderd7/thread.hpp +++ b/include/renderd7/thread.hpp @@ -10,20 +10,6 @@ using CTRU_Thread = Thread; #define THREAD_STACK_SIZE 0x1000 namespace RenderD7 { -namespace Threads { -inline bool threadrunning = false; - -struct Thread { - Handle handle; - void (*ep)(void); - bool finished; - void *stacktop; -}; - -bool Create(); -bool Join(); -void Exit(); -} // namespace Threads class Thread { public: /** diff --git a/include/renderd7/tween.hpp b/include/renderd7/tween.hpp deleted file mode 100644 index 1efaf70..0000000 --- a/include/renderd7/tween.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#include - -namespace rnd7 { -enum class TweenType : int { Position = 1, Color, Alpha }; - -enum class TweenLoop : int { - None = 1, - Loop = 2, -}; - -enum class TweenDirection : int { Current, Forward, Backward }; - -enum class TweenState : int { Playing = 1, Stopped }; -class Tween { -public: - Tween(float from, float to, float duration, TweenLoop loop, TweenState state); -}; -} // namespace rnd7 diff --git a/source/Sprite.cpp b/source/Sprite.cpp index fc0138b..598cdb3 100644 --- a/source/Sprite.cpp +++ b/source/Sprite.cpp @@ -22,7 +22,7 @@ void RenderD7::Sprite::SetRotation(float rotation) { void RenderD7::Sprite::Rotate(float speed) { C2D_SpriteRotateDegrees(&this->sprite, speed); } -float RenderD7::Sprite::getHeigh() { return this->sprite.params.pos.h; } +float RenderD7::Sprite::getHeight() { return this->sprite.params.pos.h; } float RenderD7::Sprite::getWidth() { return this->sprite.params.pos.w; } float RenderD7::Sprite::getPosX() { return this->sprite.params.pos.x; } float RenderD7::Sprite::getPosY() { return this->sprite.params.pos.y; } diff --git a/source/Tasks.cpp b/source/Tasks.cpp index bf7ac7a..53ae98f 100644 --- a/source/Tasks.cpp +++ b/source/Tasks.cpp @@ -6,7 +6,7 @@ static std::vector threads; -void Tasks::create(ThreadFunc entrypoint) { +void RenderD7::Tasks::create(ThreadFunc entrypoint) { s32 prio = 0; svcGetThreadPriority(&prio, CUR_THREAD_HANDLE); Thread thread = threadCreate((ThreadFunc)entrypoint, NULL, 64 * 1024, @@ -14,7 +14,7 @@ void Tasks::create(ThreadFunc entrypoint) { threads.push_back(thread); } -void Tasks::destroy(void) { +void RenderD7::Tasks::destroy(void) { for (u32 i = 0; i < threads.size(); i++) { threadJoin(threads.at(i), U64_MAX); threadFree(threads.at(i)); diff --git a/source/Toast.cpp b/source/Toast.cpp index e12941b..db29c01 100644 --- a/source/Toast.cpp +++ b/source/Toast.cpp @@ -4,14 +4,6 @@ RenderD7::Toast::Toast(std::string head, std::string msg) { this->head = head; this->msg = msg; - /*this->toast = RenderD7::BitmapPrinter(400, 70); - this->toast.ClearBlank(); - this->toast.DrawRectFilled(0, 0, 400, 70, 40, 40, 40, 255); - this->toast.DrawRectFilled(0, 0, 400, 25, 70, 70, 70, 255); - this->toast.DrawDebugText(4, 5, 0, RenderD7::Color::Hex("#ffffff"), - this->head); this->toast.DrawDebugText(4, 40, 0, - RenderD7::Color::Hex("#ffffff"), this->msg); - this->toastrendered->LoadPFromBuffer(BitmapConverter::ConvertData(toast.GetBitmap().DATA()));*/ } void RenderD7::Toast::Draw(void) const { @@ -22,7 +14,6 @@ void RenderD7::Toast::Draw(void) const { head); RenderD7::Draw::Text(2, msgposy + 30, 0.6f, RenderD7::Color::Hex("#ffffff"), msg); - // toastrendered->Draw(0, msgposy); } void RenderD7::Toast::Logic() { diff --git a/source/renderd7.cpp b/source/renderd7.cpp index c13ae68..f28ccae 100644 --- a/source/renderd7.cpp +++ b/source/renderd7.cpp @@ -114,22 +114,12 @@ std::vector string_to_lines(std::string input_str) { void Npifade() { if (fadein) { if (fadealpha < 255) { - RenderD7::OnScreen(Top); - RenderD7::Draw::Rect(0, 0, RenderD7::IsRD7SR() ? 800 : 400, 240, - ((fadealpha << 24) | 0x00000000)); - RenderD7::OnScreen(Bottom); - RenderD7::Draw::Rect(0, 0, 320, 240, ((fadealpha << 24) | 0x00000000)); fadealpha += 3; } else { fadein = false; } } else if (fadeout) { if (fadealpha > 0) { - RenderD7::OnScreen(Top); - RenderD7::Draw::Rect(0, 0, RenderD7::IsRD7SR() ? 800 : 400, 240, - ((fadealpha << 24) | 0x00000000)); - RenderD7::OnScreen(Bottom); - RenderD7::Draw::Rect(0, 0, 320, 240, ((fadealpha << 24) | 0x00000000)); fadealpha -= 3; } else { fadeout = false; @@ -144,25 +134,28 @@ void Npifade() { SceneFadeWait = false; } // No fade - RenderD7::OnScreen(Top); - RenderD7::Draw::Rect(0, 0, RenderD7::IsRD7SR() ? 800 : 400, 240, - ((fadealpha << 24) | 0x00000000)); - RenderD7::OnScreen(Bottom); - RenderD7::Draw::Rect(0, 0, 320, 240, ((fadealpha << 24) | 0x00000000)); } + RenderD7::OnScreen(Top); + RenderD7::Draw::Rect(0, 0, RenderD7::IsRD7SR() ? 800 : 400, 240, + ((fadealpha << 24) | 0x00000000)); + RenderD7::OnScreen(Bottom); + RenderD7::Draw::Rect(0, 0, 320, 240, ((fadealpha << 24) | 0x00000000)); } void PushSplash() { C2D_SpriteSheet sheet; sheet = C2D_SpriteSheetLoadFromMem((void *)renderd7_logo, renderd7_logo_size); - C3D_FrameBegin(C3D_FRAME_SYNCDRAW); - C2D_TargetClear(Top, DSEVENBLACK); - C2D_TargetClear(Bottom, DSEVENBLACK); - RenderD7::ClearTextBufs(); - RenderD7::OnScreen(Top); - C2D_DrawImageAt(C2D_SpriteSheetGetImage(sheet, 0), 400 / 2 - 300 / 2, - 240 / 2 - 100 / 2, 0.5); - C3D_FrameEnd(0); + // Display for 2 Sec + for (int x = 0; x < 120; x++) { + C3D_FrameBegin(C3D_FRAME_SYNCDRAW); + C2D_TargetClear(Top, DSEVENBLACK); + C2D_TargetClear(Bottom, DSEVENBLACK); + RenderD7::ClearTextBufs(); + RenderD7::OnScreen(Top); + C2D_DrawImageAt(C2D_SpriteSheetGetImage(sheet, 0), 400 / 2 - 300 / 2, + 240 / 2 - 100 / 2, 0.5); + C3D_FrameEnd(0); + } C2D_SpriteSheetFree(sheet); } @@ -700,8 +693,6 @@ bool RenderD7::IsRD7SR() { return gfxIsWide(); } void RenderD7::Exit::Main() { cfgfile->write(cfgstruct); - if (RenderD7::Threads::threadrunning) - RenderD7::Threads::Exit(); C2D_TextBufDelete(TextBuf); C2D_Fini(); C3D_Fini(); @@ -713,8 +704,6 @@ void RenderD7::Exit::Main() { void RenderD7::Exit::Minimal() { cfgfile->write(cfgstruct); - if (RenderD7::Threads::threadrunning) - RenderD7::Threads::Exit(); C2D_TextBufDelete(TextBuf); C2D_Fini(); C3D_Fini(); @@ -887,13 +876,6 @@ bool RenderD7::IsNdspInit() { } } -void RenderD7::DrawList1(RenderD7::ScrollList1 &l, float txtsize, - C3D_RenderTarget *t) { - RenderD7::OnScreen(t); - RenderD7::Draw::Rect(0, 0, 400, 240, RenderD7::Color::Hex("#dddddd")); - RenderD7::Draw::Text(0, 0, 0.8f, RenderD7::Color::Hex("#ffffff"), l.Text); -} - std::string priv_fmt_bytes(int bytes) { char out[32]; @@ -1017,15 +999,17 @@ int lp = 0; void RenderD7::FrameEnd() { if (metrikd && !shouldbe_disabled) RenderD7::DrawMetrikOvl(); - if (!shouldbe_disabled) + if (!shouldbe_disabled) { OvlHandler(); + } lp++; Npifade(); + C3D_FrameEnd(0); } RenderD7::RSettings::RSettings() { - RenderD7::FadeOut(); + RenderD7::FadeIn(); cfgfile = std::make_unique(cfgpath + "/config.ini"); cfgfile->read(cfgstruct); rd7settings = true; @@ -1125,8 +1109,7 @@ void RenderD7::RSettings::Draw(void) const { RenderD7::OnScreen(Bottom); RenderD7::Draw::Rect(0, 0, 320, 240, RenderD7::Color::Hex("#eeeeee")); RenderD7::Draw::Text(0, 0, 0.7f, RenderD7::Color::Hex("#111111"), - "Press B to Get back!\ntxty: " + - std::to_string(txtposy)); + "Press B to Get back!"); } else if (m_state == RINFO) { std::string rd7ver = RENDERD7VSTRING; @@ -1190,25 +1173,24 @@ void RenderD7::RSettings::Logic(u32 hDown, u32 hHeld, u32 hUp, } if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[1])) { m_state = RCLOG; - txtposy = 0; } if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[2])) { metrikd = metrikd ? false : true; cfgstruct["metrik-settings"]["enableoverlay"] = metrikd ? "1" : "0"; } - if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[3]) && + /*if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[3]) && !metrikd) { cfgstruct["settings"]["forceFrameRate"] = Kbd(2, SWKBD_TYPE_NUMPAD); // C3D_FrameRate(RenderD7::Convert::StringtoFloat( // cfgstruct["settings"]["forceFrameRate"])); - } + }*/ if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[4])) { mt_screen = mt_screen ? 0 : 1; cfgstruct["metrik-settings"]["screen"] = mt_screen ? "1" : "0"; } - if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[5])) { + /*if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[5])) { RenderD7::AddOvl(std::make_unique()); - } + }*/ if (d7_hDown & KEY_TOUCH && RenderD7::touchTObj(d7_touch, buttons[6])) { m_state = RINFO; } @@ -1261,6 +1243,38 @@ void RenderD7::AddOvl(std::unique_ptr overlay) { } void RenderD7::DoNpiIntro() { + // May be stream in future + /*NVID_Stream* stream = new NVID_Stream(npi_intro, npi_intro_size); + int c = 0; + float xc = 0; + NVID_Image nimg; + RenderD7::Image img; + uint64_t lastT = osGetTime(); + stream->ReadNext(nimg); + while(true) + { + shouldbe_disabled = true; + cnttttt = 0; + C3D_FrameBegin(C3D_FRAME_SYNCDRAW); + C2D_TargetClear(Top, RenderD7::Color::Hex("#000000")); + C2D_TargetClear(Bottom, RenderD7::Color::Hex("#000000")); + RenderD7::ClearTextBufs(); + RenderD7::OnScreen(Top); + + img.LoadPixels(nimg.w, nimg.h, nimg.bpp, nimg.pBuf); + img.Draw(0, 0); + xc += osGetTime() - lastT; + lastT = osGetTime(); + if (xc > 24 / 60) { + c++; + if(!stream->ReadNext(nimg)) + break; + xc = 0; + } + if (c > 59) + break; + C3D_FrameEnd(0); + }*/ auto images = LoadMemNVID(npi_intro, npi_intro_size); int c = 0; float xc = 0; @@ -1289,7 +1303,7 @@ void RenderD7::DoNpiIntro() { } } -void RenderD7::FadeIn() { +void RenderD7::FadeOut() { if (!waitFade) { fadein = true; fadealpha = 0; @@ -1297,7 +1311,7 @@ void RenderD7::FadeIn() { } } -void RenderD7::FadeOut() { +void RenderD7::FadeIn() { if (!waitFade) { fadeout = true; fadealpha = 255; diff --git a/source/thread.cpp b/source/thread.cpp index 7db3968..b79098f 100644 --- a/source/thread.cpp +++ b/source/thread.cpp @@ -1,6 +1,5 @@ #include namespace RenderD7 { -void Threads::Exit() {} Thread::Thread() : m_started(false), m_running(false) { /* do nothing */ }