From 898162121dbeb6768974cd4497ec09245c729393 Mon Sep 17 00:00:00 2001 From: Zy Date: Fri, 11 Oct 2024 20:22:15 +0200 Subject: [PATCH] dev: clean docs and everything, add TODOs --- LICENSE.txt | 22 +---------- Makefile | 4 ++ README.md | 70 +-------------------------------- embedassets.sh | 1 + include/mlx.h | 3 -- include/mlx3ds_embeddedassets.h | 3 +- include/mlx3ds_typealiases.h | 7 ++-- include/mlx_hook.h | 3 +- include/mlx_image.h | 15 +++---- include/mlx_init.h | 3 -- include/mlx_put.h | 18 +++++---- include/mlx_unknown.h | 5 +-- include/mlx_window.h | 5 +-- source/mlx_inline.c | 8 ++++ source/mlx_int.h | 9 ++++- source/mlx_int_str_to_wordtab.c | 7 ++++ source/mlx_internal.cpp | 2 + source/mlx_internal.h | 2 +- source/mlx_rgb.c | 7 ++++ source/mlx_xpm.c | 7 ++++ 20 files changed, 74 insertions(+), 127 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 0bc98f0..feb4f1b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,21 +1 @@ -MIT License - -Copyright (c) 2017 [Brandon W.] - -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 - +TODO being compatible with licenses from: 3ds-template, minilibx, xpm and devkitpro diff --git a/Makefile b/Makefile index 60085a2..6ee8604 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +# From (where?) (<-- TODO answer) +# Modified by Zy to work with the MinilibX For 3DS project +# (at https://github.com/frzysk/mlx3ds). + #--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- diff --git a/README.md b/README.md index dbf436c..ed19324 100644 --- a/README.md +++ b/README.md @@ -1,69 +1 @@ -# 3ds-template - -A starter template for various 3DS homebrew applications. This template is geared specifically towards the Code::Blocks IDE. This template can also be used without Code::Blocks just use the `Makefile` and directory structure provided. - -This is designed to be a simple and fairly minimal setup required to begin developing homebrew for the 3ds system. As such it doesn't include everything needed to build everything out of the box if you want to build 3ds or cia homebrew. - -## Usage - -| Targets | Action | -| ------------| ----------------------------------------------------------------------------------------- | -| 3ds | Builds `.3ds`. 1 -| 3dsx | Builds `.3dsx` and `.smdh`. -| cia | Builds `.cia`. 1 -| citra | Builds and automatically runs `citra` for testing.2 -| elf | Builds `.elf`. -| release | Release build, creates a `cia`, `3ds`, and a zip file containing the `smdh` and `3dsx`. 3 - -**Notes:** -* 1 This requires having [makerom] and [bannertool] in your `$PATH` -* 2 `make citra` requires having [citra] installed and in your `$PATH` -* 3 If you are on Windows you will need both of the following in your `$PATH` [zip] and [libbz2.dll] - -## Setting up devkitPro -* Follow the steps installing devkitPro at the gbatemp [wiki] - -### If you want to build cia and 3ds then follow these extra steps: -* Aquire makerom and bannertool binaries from [buildtools], or compile them yourself from [makerom] and [bannertool] -* Copy the makerom/bannertool to `$DEVKITARM/bin` or some other directory in your `$PATH` - -## Code::Blocks Setup -1. Simply open `3ds.cbp` in Code::Blocks -2. Choose File > Save as user-template and enter a template name. The project setup is now a user template to create new projects. -3. When creating a new project select File > New > From template and follow the wizard's instructions. -4. Ensure you have the environment variables plugin installed (in linux you can install this by installing the codeblocks-contrib package) -5. Choose Settings > Environment and scroll down to the Environment Variables section. -6. Add `DEVKITPRO` and point it to where devkitpro is installed -7. Add `DEVKITARM` and point it to where devkitarm is. - -To compile in Code::Blocks simply select your target from the list and click the Gear icon to automatically invoke the `Makefile` - -**Note** Make sure you are using MSYS2's make (make.exe) and not MINGW's make (mingw32-make.exe) - -## Creating a new project -1. Make a new Code::Blocks project via a user-template you just created above. Or simply copy this directory. -2. (Only needed for cia/3ds builds) Edit the file `resources/AppInfo` - 1. Edit those values and ensure you choose a unique id see [unique_id_list]. - 2. Replace the existing files in the `resources` directory to suit your needs. - -**Note** please ensure that no folder/directory used in the project contains spaces. Devkitpro's Makefiles apparently does not like this. -That is, do not have it in a folder like `C:/3DS Hacking/3ds-template` rather `C:/3DS_Hacking/3ds-template` - -## Credits -All of this would not have been possible without the work of -* [Smealum](https://github.com/smealum) -* [Steveice10](https://github.com/Steveice10) for the [buildtools] -* [amaredeus](https://github.com/amaredeus) for various improvements to the template (such as the formatting in this README) - - -[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax) - - -[buildtools]: -[bannertool]: -[citra]: -[libbz2.dll]: -[makerom]: -[unique_id_list]: -[wiki]: -[zip]: +TODO README.md diff --git a/embedassets.sh b/embedassets.sh index 16afa68..c2a7d49 100755 --- a/embedassets.sh +++ b/embedassets.sh @@ -1,6 +1,7 @@ #!/bin/bash # USED BY MAKEFILE, DO NOT MOVE OR RENAME +# TODO embedassets.sh: docs ASSETS_FULL_DIR=$1 shift diff --git a/include/mlx.h b/include/mlx.h index dde4bf4..46f140d 100644 --- a/include/mlx.h +++ b/include/mlx.h @@ -17,9 +17,6 @@ * doesn't do anything. The returned values marked as "unused" are undefined. * Both are kept as is to stay as compatible as possible with project using the * original MinilibX implementation. - * - * When using a x,y couple to define a position, the origin (0,0) is always at - * the top-left corner of the image. */ /** diff --git a/include/mlx3ds_embeddedassets.h b/include/mlx3ds_embeddedassets.h index 0520cea..e1bfc93 100644 --- a/include/mlx3ds_embeddedassets.h +++ b/include/mlx3ds_embeddedassets.h @@ -6,7 +6,8 @@ */ /** - * Functions to use the assets embedded with the program with embedassets.sh + * This file contains functions to use the assets embedded with the program + * with embedassets.sh. */ #ifndef MLX3DS_ASSETS_H diff --git a/include/mlx3ds_typealiases.h b/include/mlx3ds_typealiases.h index 9ef357c..cef1a96 100644 --- a/include/mlx3ds_typealiases.h +++ b/include/mlx3ds_typealiases.h @@ -6,9 +6,10 @@ */ /** - * Define different type aliases for the different void* values used with - * the mlx_ functions. + * This file contains different typedefs for void*, to differenciate between + * the different void* used by the MLX functions. */ + #ifndef MLX3DS_TYPEALIASES_H # define MLX3DS_TYPEALIASES_H @@ -21,4 +22,4 @@ typedef void *t_win; /// @brief Reference to an image in memory. typedef void *t_image; -#endif \ No newline at end of file +#endif diff --git a/include/mlx_hook.h b/include/mlx_hook.h index 847eda9..cea3161 100644 --- a/include/mlx_hook.h +++ b/include/mlx_hook.h @@ -20,7 +20,7 @@ */ /** - * Functions to manage window events. + * This file contains the functions used to manage window events. */ #ifndef MLX_HOOK_H @@ -43,7 +43,6 @@ int _mlx_mouse_hook(t_win win_ptr, int (*funct_ptr)(), void *param); /// @param funct_ptr Function to call when the event occurs. `keycode` is the /// key pressed (note that they are obviously different than /// the keyboard ones, use the KEY_* constants from hid.h)). -/// (TODO what was the name of the key constants use with mlx?) /// `param` is set as the address given to mlx_key_hook(). /// The return value is unused. /// @param param Address to pass to the function every time it is called. diff --git a/include/mlx_image.h b/include/mlx_image.h index 4649481..d2cde6a 100644 --- a/include/mlx_image.h +++ b/include/mlx_image.h @@ -17,13 +17,14 @@ * doesn't do anything. The returned values marked as "unused" are undefined. * Both are kept as is to stay as compatible as possible with project using the * original MinilibX implementation. - * - * When using a x,y couple to define a position, the origin (0,0) is always at - * the top-left corner of the image. */ /** - * Functions to import, create, modify and display images. + * This file contains functions to import, create, modify and display images. + * + * When using a x,y couple to define a position, the origin (0,0) is always at + * the top-left corner of the image (despite how the 3ds screen works, for those + * who know). */ #ifndef MLX_IMAGE_H @@ -67,17 +68,17 @@ char *mlx_get_data_addr(t_image img_ptr, int *bits_per_pixel, int mlx_put_image_to_window(t_mlx mlx_ptr, t_win win_ptr, t_image img_ptr, int x, int y); -// ??? TODO docs +// ??? TODO docs xpm_to_image // width & height CAN be null (check please :3) t_image mlx_xpm_to_image(t_mlx mlx_ptr, const char **xpm_data, int *width, int *height); -// ??? +// ??? TODO docs xpm_file_to_image // width & height CAN be null (check please :3) t_image _mlx_xpm_file_to_image(t_mlx mlx_ptr, char *filename, int *width, int *height); -/// @brief Destroy an image. +/// @brief Destroy an image to avoid leaks. /// /// @param mlx_ptr mlx connection identifier returned by mlx_init(). /// @param img_ptr Image to destroy. diff --git a/include/mlx_init.h b/include/mlx_init.h index e424af0..f6d99a7 100644 --- a/include/mlx_init.h +++ b/include/mlx_init.h @@ -17,9 +17,6 @@ * doesn't do anything. The returned values marked as "unused" are undefined. * Both are kept as is to stay as compatible as possible with project using the * original MinilibX implementation. - * - * When using a x,y couple to define a position, the origin (0,0) is always at - * the top-left corner of the image. */ /** diff --git a/include/mlx_put.h b/include/mlx_put.h index 510653d..5c5d701 100644 --- a/include/mlx_put.h +++ b/include/mlx_put.h @@ -17,15 +17,16 @@ * doesn't do anything. The returned values marked as "unused" are undefined. * Both are kept as is to stay as compatible as possible with project using the * original MinilibX implementation. - * - * When using a x,y couple to define a position, the origin (0,0) is always at - * the top-left corner of the image. */ /** - * Functions to draw specific things on the window. + * All the functions to draw specific things on the window. * - * Note that mlx_put_image_to_window() is in mlx_image.h + * When using a x,y couple to define a position, the origin (0,0) is always at + * the top-left corner of the image (despite how the 3ds screen works, for those + * who know). + * + * (The function mlx_put_image_to_window() is declared in mlx_image.h) */ #ifndef MLX_PUT_H @@ -34,8 +35,11 @@ # include "mlx3ds_typealiases.h" /// @brief Draws a pixel on the window. +/// @details Way slower than even the original MinilibX. +/// Bad function. Those who use it are condemned to have unexplicable +/// segfaults in exams. /// -/// @param mlx_ptr mlx connection identifier returned by mlx_init(). +/// @param mlx_ptr mlx connectio n identifier returned by mlx_init(). /// @param win_ptr Window to affect. /// @param x x position of the pixel to set. /// @param y y position of the pixel to set. @@ -54,7 +58,7 @@ int mlx_pixel_put(t_mlx mlx_ptr, t_win win_ptr, int x, int y, int color); int _mlx_string_put(void *mlx_ptr, void *win_ptr, int x, int y, int color, char *string); -// ??? +// TODO docs set_font void _mlx_set_font(void *mlx_ptr, void *win_ptr, char *name); #endif diff --git a/include/mlx_unknown.h b/include/mlx_unknown.h index 4ae9095..c445cbc 100644 --- a/include/mlx_unknown.h +++ b/include/mlx_unknown.h @@ -17,9 +17,6 @@ * doesn't do anything. The returned values marked as "unused" are undefined. * Both are kept as is to stay as compatible as possible with project using the * original MinilibX implementation. - * - * When using a x,y couple to define a position, the origin (0,0) is always at - * the top-left corner of the image. */ /** @@ -66,4 +63,4 @@ int _mlx_do_key_autorepeatoff(t_mlx mlx_ptr); // ??? int _mlx_do_key_autorepeaton(t_mlx mlx_ptr); -#endif \ No newline at end of file +#endif diff --git a/include/mlx_window.h b/include/mlx_window.h index 80aeca1..bd68b2f 100644 --- a/include/mlx_window.h +++ b/include/mlx_window.h @@ -17,13 +17,10 @@ * doesn't do anything. The returned values marked as "unused" are undefined. * Both are kept as is to stay as compatible as possible with project using the * original MinilibX implementation. - * - * When using a x,y couple to define a position, the origin (0,0) is always at - * the top-left corner of the image. */ /** - * Functions to manage windows. + * This file contains functions to manage windows. */ #ifndef MLX_WINDOW_H diff --git a/source/mlx_inline.c b/source/mlx_inline.c index 9f7c28d..a2192a6 100644 --- a/source/mlx_inline.c +++ b/source/mlx_inline.c @@ -5,6 +5,14 @@ * at https://github.com/frzysk/mlx3ds */ +/** + * This file contains some internal functions that have to be inline for + * optimization purposes. + * + * Yes, I do include this file directly even if it's a .c file. + * What the norminette doesn't know can't hurt it. + */ + #include "3ds.h" /// @brief Write a color at a specific location of the memory, diff --git a/source/mlx_int.h b/source/mlx_int.h index 72a7be3..7c2fd4d 100644 --- a/source/mlx_int.h +++ b/source/mlx_int.h @@ -8,12 +8,17 @@ ** Last update Wed May 25 16:44:16 2011 Olivier Crouzet */ - - /* ** Internal settings for MiniLibX */ +/** + * Modified by Zy to work with the MinilibX For 3DS project + * (at https://github.com/frzysk/mlx3ds). + */ + +// TODO: from mlx xpm: clean + #ifndef MLX_INT_H # define MLX_INT_H diff --git a/source/mlx_int_str_to_wordtab.c b/source/mlx_int_str_to_wordtab.c index 3f50dfe..9451f44 100644 --- a/source/mlx_int_str_to_wordtab.c +++ b/source/mlx_int_str_to_wordtab.c @@ -8,6 +8,13 @@ ** Last update Fri Dec 14 11:02:09 2001 Charlie Root */ +/** + * Modified by Zy to work with the MinilibX For 3DS project + * (at https://github.com/frzysk/mlx3ds). + */ + +// TODO: from mlx xpm: clean + #include "mlx_int.h" // [USED] [FULL] diff --git a/source/mlx_internal.cpp b/source/mlx_internal.cpp index 3a5f5b4..e65fbc0 100644 --- a/source/mlx_internal.cpp +++ b/source/mlx_internal.cpp @@ -5,6 +5,8 @@ * at https://github.com/frzysk/mlx3ds */ +// TODO mlx_internal.cpp: embed uc_pause() and change to .c file + #include "utilsconsole.hpp" extern "C" { diff --git a/source/mlx_internal.h b/source/mlx_internal.h index 8e0e070..cc456f4 100644 --- a/source/mlx_internal.h +++ b/source/mlx_internal.h @@ -6,7 +6,7 @@ */ /** - * Internal utils of the mlx3ds. + * This file contains internal utils. */ #ifndef MLX_INTERNAL_H diff --git a/source/mlx_rgb.c b/source/mlx_rgb.c index 0cfccf6..e18086c 100644 --- a/source/mlx_rgb.c +++ b/source/mlx_rgb.c @@ -3,6 +3,13 @@ ** the XFree86 distribution. */ +/** + * Modified by Zy to work with the MinilibX For 3DS project + * (at https://github.com/frzysk/mlx3ds). + */ + +// TODO: from mlx xpm: clean + #include "mlx_int.h" struct s_col_name mlx_col_name[] = diff --git a/source/mlx_xpm.c b/source/mlx_xpm.c index 0664432..2015d57 100644 --- a/source/mlx_xpm.c +++ b/source/mlx_xpm.c @@ -8,6 +8,13 @@ ** Last update Sat Oct 1 14:56:13 2005 Olivier Crouzet */ +/** + * Modified by Zy to work with the MinilibX For 3DS project + * (at https://github.com/frzysk/mlx3ds). + */ + +// TODO: from mlx xpm: clean + #include "mlx_int.h" #include "mlx.h" #include "mlx_internal.h"