diff --git a/stdme/Filelist.me.mk b/stdme/Filelist.me.mk index 03b7c42f..b7582c81 100644 --- a/stdme/Filelist.me.mk +++ b/stdme/Filelist.me.mk @@ -1,21 +1,4 @@ SRC_FILES = \ -blx/blx \ -blx/blx_create_fontsheet \ -blx/blx_handlers \ -blx/blx_keycode \ -blx/colors \ -blx/draw/draw \ -blx/draw/draw_sprite \ -blx/draw/draw_string \ -blx/inputs \ -blx/logic \ -blx/sprite/draw_image \ -blx/sprite/draw_pixel_onto \ -blx/sprite/draw_string \ -blx/sprite/free_image \ -blx/sprite/get_pixel \ -blx/sprite/new_image \ -blx/sprite/sprite_draw_onto_sprite \ char/isalnum \ char/isalpha \ char/isascii \ diff --git a/stdme/include/me/blx/blx.h b/stdme/include/me/blx/blx.h deleted file mode 100644 index 49a3d1a1..00000000 --- a/stdme/include/me/blx/blx.h +++ /dev/null @@ -1,145 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blx.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/13 17:05:45 by maiboyer #+# #+# */ -/* Updated: 2024/07/11 18:56:47 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef BLX_H -# define BLX_H - -# include "me/blx/blx_key.h" -# include "me/blx/colors.h" -# include "me/blx/inputs.h" -# include "me/blx/sprite.h" -# include "me/types.h" -# include "me/vec2/vec2.h" - -typedef struct s_blx t_blx; - -typedef struct s_blx_app -{ - t_str title; - t_u32 size_x; - t_u32 size_y; - t_u32 pixel_size; - void *data; -} t_blx_app; - -typedef bool (*t_run_function)(t_blx *ctx); -typedef void (*t_free_function)(t_blx_app app); - -typedef enum e_draw_mode -{ - REPLACE, - MASK, - ALPHA, -} t_draw_mode; - -typedef struct s_blx_data -{ - t_sprite screen; - bool exit; - t_draw_mode draw_mode; - t_sprite font; -} t_blx_data; - -typedef struct s_blx -{ - void *mlx; - void *win; - t_blx_input inputs; - t_run_function func; - t_free_function mem_free; - t_blx_app app; - t_blx_data _data; -} t_blx; - -/// @brief The main loop function -/// @param ctx the BLX context -/// @note this is the function that will be called every frame -/// @note this is an internal function, you should not call it yourself -int blx_loop_func(t_blx *ctx); - -/// @brief Initialize the BLX context -/// @param func the main loop function -/// @param free_fn the free function -/// @param data the application data -/// @return -t_blx blx_initialize(t_run_function func, \ - t_free_function free_fn, t_blx_app data); - -/// @brief Draw a sprite onto the screen -/// @param app The blx context -/// @param pos The position to draw the sprite at -/// @param spr The sprite to draw -void draw_sprite(t_blx *app, t_vi2d pos, t_sprite *spr); - -/// @brief is the key pressed -/// @param ctx the BLX context -/// @param input the key to check -/// @return true if the key is pressed, false otherwise -bool is_key_pressed(t_blx *ctx, t_keysym input); - -/// @brief is the key held -/// @param ctx the BLX context -/// @param input the key to check -/// @return true if the key is held, false otherwise -bool is_key_held(t_blx *ctx, t_keysym input); - -/// @brief is the key released -/// @param ctx the BLX context -/// @param input the key to check -/// @return true if the key is released, false otherwise -bool is_key_released(t_blx *ctx, t_keysym input); - -/// @brief Start the game -/// @param app the BLX context -void blx_run(t_blx app); - -/// @brief Free the game -/// @param app the BLX context -void blx_free(t_blx app); - -/// @brief Draw a pixel onto the screen -/// @param app the BLX context -/// @param pos the position to draw the pixel at -/// @param col the color of the pixel -void blx_draw(t_blx *app, t_vi2d pos, t_color col); - -/// @brief Clear the screen with a color -/// @param app the BLX context -/// @param col the color to clear the screen with -void blx_clear(t_blx *app, t_color col); - -/// @brief Draw a sprite onto another sprite -/// @param dest the sprite to be drawn onto -/// @param pos the position to draw the sprite at -/// @param source the sprite to draw -void sprite_draw_onto(t_sprite *dest, t_vi2d pos, - t_sprite *source); - -/// @brief Draw a string onto the screen -/// @param app the BLX context -/// @param pos the position to draw the string at -/// @param s the string to draw -/// @param col the color of the string -void blx_draw_string(t_blx *app, t_vi2d pos, - t_const_str s, t_color col); - -static inline t_draw_mode get_draw_mode(t_blx *app) -{ - return (app->_data.draw_mode); -} - -static inline void set_draw_mode(t_blx *app, t_draw_mode mode) -{ - app->_data.draw_mode = mode; -} - -#endif diff --git a/stdme/include/me/blx/blx_handlers.h b/stdme/include/me/blx/blx_handlers.h deleted file mode 100644 index 79222611..00000000 --- a/stdme/include/me/blx/blx_handlers.h +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blx_handlers.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 17:37:50 by maiboyer #+# #+# */ -/* Updated: 2023/12/21 18:32:01 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef BLX_HANDLERS_H -# define BLX_HANDLERS_H -# include "me/blx/blx_key.h" -# include "me/types.h" - -/// @brief Handle a key press event -/// @param keysym the key that was pressed -/// @param ctx the BLX context -/// @note this is an internal function, you should not call it yourself -int blx_key_pressed_handler(t_keysym keysym, t_blx *ctx); - -/// @brief Handle a key released event -/// @param keysym the key that was released -/// @param ctx the BLX context -/// @note this is an internal function, you should not call it yourself -int blx_key_released_handler(t_keysym keysym, t_blx *ctx); - -/// @brief Handle a exit event -/// @param ctx the BLX context -/// @note this is an internal function, you should not call it yourself -int blx_key_exit_handler(t_blx *ctx); - -#endif diff --git a/stdme/include/me/blx/blx_key.h b/stdme/include/me/blx/blx_key.h deleted file mode 100644 index 8c55f026..00000000 --- a/stdme/include/me/blx/blx_key.h +++ /dev/null @@ -1,199 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blx_key.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/13 18:15:50 by maiboyer #+# #+# */ -/* Updated: 2023/12/21 17:37:02 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef BLX_KEY_H -# define BLX_KEY_H - -# include "me/types.h" -# include "me/vec/vec_u8.h" - -typedef enum e_keysym -{ - KB_space = 0x0020, - KB_exclam = 0x0021, - KB_quotedbl = 0x0022, - KB_numbersign = 0x0023, - KB_dollar = 0x0024, - KB_percent = 0x0025, - KB_ampersand = 0x0026, - KB_apostrophe = 0x0027, - KB_quoteright = 0x0027, - KB_parenleft = 0x0028, - KB_parenright = 0x0029, - KB_asterisk = 0x002a, - KB_plus = 0x002b, - KB_comma = 0x002c, - KB_minus = 0x002d, - KB_period = 0x002e, - KB_slash = 0x002f, - KB_0 = 0x0030, - KB_1 = 0x0031, - KB_2 = 0x0032, - KB_3 = 0x0033, - KB_4 = 0x0034, - KB_5 = 0x0035, - KB_6 = 0x0036, - KB_7 = 0x0037, - KB_8 = 0x0038, - KB_9 = 0x0039, - KB_colon = 0x003a, - KB_semicolon = 0x003b, - KB_less = 0x003c, - KB_equal = 0x003d, - KB_greater = 0x003e, - KB_question = 0x003f, - KB_at = 0x0040, - KB_A = 0x0041, - KB_B = 0x0042, - KB_C = 0x0043, - KB_D = 0x0044, - KB_E = 0x0045, - KB_F = 0x0046, - KB_G = 0x0047, - KB_H = 0x0048, - KB_I = 0x0049, - KB_J = 0x004a, - KB_K = 0x004b, - KB_L = 0x004c, - KB_M = 0x004d, - KB_N = 0x004e, - KB_O = 0x004f, - KB_P = 0x0050, - KB_Q = 0x0051, - KB_R = 0x0052, - KB_S = 0x0053, - KB_T = 0x0054, - KB_U = 0x0055, - KB_V = 0x0056, - KB_W = 0x0057, - KB_X = 0x0058, - KB_Y = 0x0059, - KB_Z = 0x005a, - KB_bracketleft = 0x005b, - KB_backslash = 0x005c, - KB_bracketright = 0x005d, - KB_asciicircum = 0x005e, - KB_underscore = 0x005f, - KB_grave = 0x0060, - KB_quoteleft = 0x0060, - KB_a = 0x0061, - KB_b = 0x0062, - KB_c = 0x0063, - KB_d = 0x0064, - KB_e = 0x0065, - KB_f = 0x0066, - KB_g = 0x0067, - KB_h = 0x0068, - KB_i = 0x0069, - KB_j = 0x006a, - KB_k = 0x006b, - KB_l = 0x006c, - KB_m = 0x006d, - KB_n = 0x006e, - KB_o = 0x006f, - KB_p = 0x0070, - KB_q = 0x0071, - KB_r = 0x0072, - KB_s = 0x0073, - KB_t = 0x0074, - KB_u = 0x0075, - KB_v = 0x0076, - KB_w = 0x0077, - KB_x = 0x0078, - KB_y = 0x0079, - KB_z = 0x007a, - KB_braceleft = 0x007b, - KB_bar = 0x007c, - KB_braceright = 0x007d, - KB_asciitilde = 0x007e, - KB_BackSpace = 0xff08, - KB_Tab = 0xff09, - KB_Linefeed = 0xff0a, - KB_Clear = 0xff0b, - KB_Return = 0xff0d, - KB_Pause = 0xff13, - KB_Scroll_Lock = 0xff14, - KB_Sys_Req = 0xff15, - KB_Escape = 0xff1b, - KB_Delete = 0xffff, - KB_Home = 0xff50, - KB_Left = 0xff51, - KB_Up = 0xff52, - KB_Right = 0xff53, - KB_Down = 0xff54, - KB_Prior = 0xff55, - KB_Page_Up = 0xff55, - KB_Next = 0xff56, - KB_Page_Down = 0xff56, - KB_End = 0xff57, - KB_Begin = 0xff58, - KB_F1 = 0xffbe, - KB_F2 = 0xffbf, - KB_F3 = 0xffc0, - KB_F4 = 0xffc1, - KB_F5 = 0xffc2, - KB_F6 = 0xffc3, - KB_F7 = 0xffc4, - KB_F8 = 0xffc5, - KB_F9 = 0xffc6, - KB_F10 = 0xffc7, - KB_F11 = 0xffc8, - KB_F12 = 0xffc9, - KB_Shift_L = 0xffe1, - KB_Shift_R = 0xffe2, - KB_Control_L = 0xffe3, - KB_Control_R = 0xffe4, - KB_Caps_Lock = 0xffe5, - KB_Shift_Lock = 0xffe6, - KB_Meta_L = 0xffe7, - KB_Meta_R = 0xffe8, - KB_Alt_L = 0xffe9, - KB_Alt_R = 0xffea, - KB_Super_L = 0xffeb, - KB_Super_R = 0xffec, - KB_Hyper_L = 0xffed, - KB_Hyper_R = 0xffee, -} t_keysym; - -typedef struct s_blx t_blx; - -/// @brief Convert a keysym to a bit index -/// @param key the keysym to convert -/// @return the bit index -/// @note this is an internal function, you should not call it yourself -t_usize keysym_to_bit_index(t_keysym key); - -/// @brief Get a key from a key storage -/// @param key_storage the key storage -/// @param keysym the key to get -/// @return true if the key is present in the storage, false otherwise -bool get_key(t_vec_u8 *key_storage, t_keysym keysym); - -/// @brief is the key pressed -/// @param ctx The BLX context -/// @param key the key to check -/// @return true if the key is pressed, false otherwise -bool is_key_pressed(t_blx *ctx, t_keysym key); - -/// @brief is the key held -/// @param ctx The BLX context -/// @param key the key to check -/// @return true if the key is held, false otherwise -bool is_key_held(t_blx *ctx, t_keysym key); - -/// @brief is the key released -/// @param ctx The BLX context -/// @param key the key to check -/// @return true if the key is released, false otherwise -bool is_key_released(t_blx *ctx, t_keysym key); - -#endif diff --git a/stdme/include/me/blx/colors.h b/stdme/include/me/blx/colors.h deleted file mode 100644 index db4d3546..00000000 --- a/stdme/include/me/blx/colors.h +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* colors.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/13 17:49:02 by maiboyer #+# #+# */ -/* Updated: 2023/12/24 17:36:50 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef COLORS_H -# define COLORS_H - -# include "me/types.h" - -typedef __attribute__((aligned(4))) struct s_color -{ - t_u8 r; - t_u8 b; - t_u8 g; - t_u8 a; -} t_color; - -/// @brief Create a new color with an specified alpha channel -/// @param r the red channel -/// @param g the green channel -/// @param b the blue channel -/// @param alpha the alpha channel -/// @return the resulting color -t_color new_color_with_alpha(t_u8 r, t_u8 g, t_u8 b, t_u8 alpha); - -/// @brief Create a new color -/// @param r the red channel -/// @param g the green channel -/// @param b the blue channel -/// @return the resulting color -t_color new_color(t_u8 r, t_u8 g, t_u8 b); - -#endif diff --git a/stdme/include/me/blx/inputs.h b/stdme/include/me/blx/inputs.h deleted file mode 100644 index 3f1021ce..00000000 --- a/stdme/include/me/blx/inputs.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* inputs.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/13 17:38:22 by maiboyer #+# #+# */ -/* Updated: 2023/12/21 20:15:54 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef INPUTS_H -# define INPUTS_H - -# include "me/types.h" -# include "me/vec/vec_u8.h" - -# ifndef BLX_H - -typedef struct s_blx t_blx; - -# endif - -typedef struct s_blx_input -{ - t_vec_u8 keysyms_pressed; - t_vec_u8 keysyms_held; - t_vec_u8 keysyms_released; - t_u8 mouse; - -} t_blx_input; - -/// @brief Create an input manager -/// @param ctx the BLX context -/// @return the created input manager -/// @note this is an internal function, you should not call it yourself -t_blx_input create_inputs_manager(t_blx *ctx); - -#endif diff --git a/stdme/include/me/blx/sprite.h b/stdme/include/me/blx/sprite.h deleted file mode 100644 index fcaf4113..00000000 --- a/stdme/include/me/blx/sprite.h +++ /dev/null @@ -1,98 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* sprite.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 21:59:18 by maiboyer #+# #+# */ -/* Updated: 2024/01/05 00:09:47 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef SPRITE_H -# define SPRITE_H - -# include "me/blx/colors.h" -# include "me/types.h" -# include "me/vec2/vec2.h" - -# ifndef BLX_H - -typedef struct s_blx t_blx; - -# endif - -typedef struct s_sprite -{ - t_blx *ctx; - void *img; - t_i32 width; - t_i32 height; - t_u8 *data; - t_i32 bpp; - t_usize line_size; - bool big_endian; -} t_sprite; - -/// @brief Create a sprite from an XPM file -/// @param ctx the BLX context -/// @param path the path to the XPM file -/// @param[out] out the output sprite -/// @return true if an error occured, false otherwise -t_error blx_sprite_from_xpm(t_blx *ctx, t_str path, - t_sprite *out); - -/// @brief Create a new sprite -/// @param ctx the BLX context -/// @param width the width of the sprite in pixels -/// @param height the height of the sprite in pixels -/// @param out[out] the output sprite -/// @return true if an error occured, false otherwise -t_error blx_sprite_new(t_blx *ctx, t_i32 width, t_i32 height, - t_sprite *out); -/// @brief Free a sprite -/// @param img the sprite to free -void blx_sprite_free(t_sprite img); -/// @brief Draw a sprite at a position onto the screen -/// @param ctx the BLX context -/// @param pos the position to draw the sprite at -/// @param img the sprite to draw -void blx_draw_sprite_raw(t_blx *ctx, t_vi2d pos, - t_sprite *img); - -/// @brief Draw a pixel onto the sprite -/// @param img the sprite to draw onto -/// @param pos the position to draw the pixel at -/// @param col the color of the pixel -void sprite_draw(t_sprite *img, t_vi2d pos, t_color col); - -/// @brief Clear a sprite with a color -/// @param img the sprite to clear -/// @param col the color to clear the sprite with -void sprite_clear(t_sprite *img, t_color col); - -/// @brief Get the color of a pixel on a sprite -/// @param spr the sprite to get the pixel from -/// @param pos the position of the pixel -/// @param[out] out the color of the pixel -/// @return true if an error occured, false otherwise -t_error sprite_get_pixel(t_sprite *spr, t_vi2d pos, - t_color *out); - -/// @brief Draw a sprite onto another sprite -/// @param dest The sprite to be drawn onto -/// @param pos The position to draw the sprite at -/// @param source The sprite to draw -void sprite_draw_onto(t_sprite *dest, t_vi2d pos, - t_sprite *source); - -/// @brief Draw a string onto a sprite -/// @param spr The sprite to draw onto -/// @param pos The position to draw the string at -/// @param sText The string to draw -/// @param col The color of the string -void sprite_draw_string(t_sprite *spr, t_vi2d pos, - t_const_str sText, t_color col); - -#endif diff --git a/stdme/include/me/blx/xdata.h b/stdme/include/me/blx/xdata.h deleted file mode 100644 index 80a04676..00000000 --- a/stdme/include/me/blx/xdata.h +++ /dev/null @@ -1,78 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* xdata.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 17:20:57 by maiboyer #+# #+# */ -/* Updated: 2023/12/21 20:15:32 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef XDATA_H -# define XDATA_H - -# define KEYPRESS 2 -# define KEYRELEASE 3 -# define BUTTONPRESS 4 -# define BUTTONRELEASE 5 -# define MOTIONNOTIFY 6 -# define ENTERNOTIFY 7 -# define LEAVENOTIFY 8 -# define FOCUSIN 9 -# define FOCUSOUT 10 -# define KEYMAPNOTIFY 11 -# define EXPOSE 12 -# define GRAPHICSEXPOSE 13 -# define NOEXPOSE 14 -# define VISIBILITYNOTIFY 15 -# define CREATENOTIFY 16 -# define DESTROYNOTIFY 17 -# define UNMAPNOTIFY 18 -# define MAPNOTIFY 19 -# define MAPREQUEST 20 -# define REPARENTNOTIFY 21 -# define CONFIGURENOTIFY 22 -# define CONFIGUREREQUEST 23 -# define GRAVITYNOTIFY 24 -# define RESIZEREQUEST 25 -# define CIRCULATENOTIFY 26 -# define CIRCULATEREQUEST 27 -# define PROPERTYNOTIFY 28 -# define SELECTIONCLEAR 29 -# define SELECTIONREQUEST 30 -# define SELECTIONNOTIFY 31 -# define COLORMAPNOTIFY 32 -# define CLIENTMESSAGE 33 -# define MAPPINGNOTIFY 34 -# define GENERICEVENT 35 - -# define NOEVENTMASK 0b0L -# define KEYPRESSMASK 0b1L -# define KEYRELEASEMASK 0b10L -# define BUTTONPRESSMASK 0b100L -# define BUTTONRELEASEMASK 0b1000L -# define ENTERWINDOWMASK 0b10000L -# define LEAVEWINDOWMASK 0b100000L -# define POINTERMOTIONMASK 0b1000000L -# define POINTERMOTIONHINTMASK 0b10000000L -# define BUTTON1MOTIONMASK 0b100000000L -# define BUTTON2MOTIONMASK 0b1000000000L -# define BUTTON3MOTIONMASK 0b10000000000L -# define BUTTON4MOTIONMASK 0b100000000000L -# define BUTTON5MOTIONMASK 0b1000000000000L -# define BUTTONMOTIONMASK 0b10000000000000L -# define KEYMAPSTATEMASK 0b100000000000000L -# define EXPOSUREMASK 0b1000000000000000L -# define VISIBILITYCHANGEMASK 0b10000000000000000L -# define STRUCTURENOTIFYMASK 0b100000000000000000L -# define RESIZEREDIRECTMASK 0b1000000000000000000L -# define SUBSTRUCTURENOTIFYMASK 0b10000000000000000000L -# define SUBSTRUCTUREREDIRECTMASK 0b100000000000000000000L -# define FOCUSCHANGEMASK 0b1000000000000000000000L -# define PROPERTYCHANGEMASK 0b10000000000000000000000L -# define COLORMAPCHANGEMASK 0b100000000000000000000000L -# define OWNERGRABBUTTONMASK 0b1000000000000000000000000L - -#endif diff --git a/stdme/src/blx/blx.c b/stdme/src/blx/blx.c deleted file mode 100644 index 5d785981..00000000 --- a/stdme/src/blx/blx.c +++ /dev/null @@ -1,75 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blx.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/14 18:01:06 by maiboyer #+# #+# */ -/* Updated: 2024/05/14 18:39:41 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/blx_handlers.h" -#include "me/blx/sprite.h" -#include "me/blx/inputs.h" -#include "me/blx/xdata.h" -#include "me/types.h" -#include "me/mem/mem.h" -#include "me/vec/vec_u8.h" -#include "me/printf/printf.h" -#include -#include -#include - -void blx_create_fontsheet(t_blx *app); - -t_blx blx_initialize(t_run_function func, t_free_function free_fn, - t_blx_app data) -{ - t_blx ctx; - - ctx = (t_blx){.func = func, .app = data, .mem_free = free_fn}; - ctx.mlx = mlx_init(); - if (ctx.mlx == NULL) - (me_eprintf("Error:\nfailed to inialize blx (mlx) !\n"), exit(1)); - ctx.inputs = create_inputs_manager(&ctx); - ctx.win = mlx_new_window(ctx.mlx, data.size_x * data.pixel_size, data.size_y - * data.pixel_size, data.title); - if (!blx_sprite_new(&ctx, data.size_x * data.pixel_size, data.size_y - * data.pixel_size, &ctx._data.screen)) - (me_eprintf("Error:\nfailed to inialize blx (screen) !\n"), exit(1)); - blx_create_fontsheet(&ctx); - return (ctx); -} - -//mlx_do_key_autorepeatoff(app.mlx); -void blx_run(t_blx app) -{ - mlx_hook(app.win, KEYPRESS, KEYPRESSMASK, &blx_key_pressed_handler, &app); - mlx_hook(app.win, KEYRELEASE, KEYRELEASEMASK, &blx_key_released_handler, - &app); - mlx_hook(app.win, DESTROYNOTIFY, NOEVENTMASK, &blx_key_exit_handler, &app); - mlx_loop_hook(app.mlx, &blx_loop_func, &app); - mlx_loop(app.mlx); -} - -void blx_free(t_blx app) -{ - blx_sprite_free(app._data.screen); - blx_sprite_free(app._data.font); - mlx_do_key_autorepeaton(app.mlx); - if (app.mem_free) - app.mem_free(app.app); - if (app.win) - mlx_destroy_window(app.mlx, app.win); - if (app.mlx) - { - mlx_destroy_display(app.mlx); - mem_free(app.mlx); - } - vec_u8_free(app.inputs.keysyms_held); - vec_u8_free(app.inputs.keysyms_pressed); - vec_u8_free(app.inputs.keysyms_released); -} diff --git a/stdme/src/blx/blx_create_fontsheet.c b/stdme/src/blx/blx_create_fontsheet.c deleted file mode 100644 index 0bda1423..00000000 --- a/stdme/src/blx/blx_create_fontsheet.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blx_create_fontsheet.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/27 19:18:44 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 20:10:02 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/sprite.h" -#include "me/types.h" -#include "me/printf/printf.h" -#include -#include - -#define FONT_SHEET_PATH "textures/font.xpm" - -void blx_create_fontsheet(t_blx *app) -{ - if (!blx_sprite_from_xpm(app, FONT_SHEET_PATH, &app->_data.font)) - { - me_eprintf("Error:\nCouldn't open sprite sheet !\n"); - exit(5); - } -} diff --git a/stdme/src/blx/blx_handlers.c b/stdme/src/blx/blx_handlers.c deleted file mode 100644 index 37fac36e..00000000 --- a/stdme/src/blx/blx_handlers.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blx_handlers.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 17:44:55 by maiboyer #+# #+# */ -/* Updated: 2023/12/21 19:59:47 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/blx_handlers.h" -#include "me/blx/blx_key.h" -#include -#include - -int blx_key_pressed_handler(t_keysym keysym, t_blx *ctx) -{ - t_usize bit_index; - - bit_index = keysym_to_bit_index(keysym); - if (bit_index / 8 >= ctx->inputs.keysyms_pressed.len) - return (0); - if (is_key_held(ctx, bit_index)) - return (0); - ctx->inputs.keysyms_pressed.buffer[bit_index / 8] |= ((t_u8)1 << (bit_index - % 8)); - return (1); -} - -int blx_key_released_handler(t_keysym keysym, t_blx *ctx) -{ - t_usize bit_index; - - bit_index = keysym_to_bit_index(keysym); - if (bit_index / 8 >= ctx->inputs.keysyms_released.len) - return (0); - ctx->inputs.keysyms_held.buffer[bit_index / 8] &= ~((t_u8)1 << (bit_index - % 8)); - ctx->inputs.keysyms_pressed.buffer[bit_index / 8] &= ~((t_u8)1 << (bit_index - % 8)); - ctx->inputs.keysyms_released.buffer[bit_index / 8] |= ((t_u8)1 << (bit_index - % 8)); - return (1); -} - -int blx_key_exit_handler(t_blx *app) -{ - app->_data.exit = true; - return (1); -} diff --git a/stdme/src/blx/blx_keycode.c b/stdme/src/blx/blx_keycode.c deleted file mode 100644 index 21a77f2f..00000000 --- a/stdme/src/blx/blx_keycode.c +++ /dev/null @@ -1,50 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blx_keysym.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/14 15:07:52 by maiboyer #+# #+# */ -/* Updated: 2023/12/14 15:58:17 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/blx_key.h" -#include "me/types.h" -#include "me/vec/vec_u8.h" - -t_usize keysym_to_bit_index(t_keysym key) -{ - if (key < 0xff00) - return ((((t_usize)key) & 0xff) + 0x0000); - if (key >= 0xff00) - return ((((t_usize)key) & 0xff) + 0x0100); - return (0); -} - -bool get_key(t_vec_u8 *key_storage, t_keysym keysym) -{ - t_usize index; - - index = keysym_to_bit_index(keysym); - if (index == 0 || index / 8 > key_storage->len) - return (false); - return (!!(key_storage->buffer[index / 8] & (1 << (index % 8)))); -} - -bool is_key_pressed(t_blx *ctx, t_keysym key) -{ - return (get_key(&ctx->inputs.keysyms_pressed, key)); -} - -bool is_key_held(t_blx *ctx, t_keysym key) -{ - return (get_key(&ctx->inputs.keysyms_held, key)); -} - -bool is_key_released(t_blx *ctx, t_keysym key) -{ - return (get_key(&ctx->inputs.keysyms_released, key)); -} diff --git a/stdme/src/blx/colors.c b/stdme/src/blx/colors.c deleted file mode 100644 index b352d225..00000000 --- a/stdme/src/blx/colors.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* colors.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/14 16:01:18 by maiboyer #+# #+# */ -/* Updated: 2023/12/27 16:26:30 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/colors.h" -#include "me/types.h" - -t_color new_color_with_alpha(t_u8 r, t_u8 g, t_u8 b, t_u8 alpha) -{ - return ((t_color){.r = r, .g = g, .b = b, .a = alpha}); -} - -t_color new_color(t_u8 r, t_u8 g, t_u8 b) -{ - return (new_color_with_alpha(r, g, b, 0x00)); -} diff --git a/stdme/src/blx/draw/draw.c b/stdme/src/blx/draw/draw.c deleted file mode 100644 index 8bee4171..00000000 --- a/stdme/src/blx/draw/draw.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* draw.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 20:19:59 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 15:05:17 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/sprite.h" -#include -#include - -void blx_clear(t_blx *app, t_color col) -{ - sprite_clear(&app->_data.screen, col); -} - -void blx_draw(t_blx *app, t_vi2d pos, t_color col) -{ - t_usize i; - t_usize j; - - if (get_draw_mode(app) == MASK && col.a != 0) - return ; - i = 0; - while (i < app->app.pixel_size) - { - j = 0; - while (j < app->app.pixel_size) - { - sprite_draw(&app->_data.screen, vi2d(pos.x * app->app.pixel_size - + j, pos.y * app->app.pixel_size + i), col); - j++; - } - i++; - } -} diff --git a/stdme/src/blx/draw/draw_sprite.c b/stdme/src/blx/draw/draw_sprite.c deleted file mode 100644 index f6188bc9..00000000 --- a/stdme/src/blx/draw/draw_sprite.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* draw_sprite.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/26 22:12:31 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 15:06:55 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/sprite.h" -#include "me/types.h" - -void draw_sprite(t_blx *app, t_vi2d pos, t_sprite *spr) -{ - t_vi2d p; - t_color col; - - p.y = 0; - while (p.y < spr->height) - { - p.x = 0; - while (p.x < spr->width) - { - sprite_get_pixel(spr, p, &col); - blx_draw(app, vi2d_add(pos, p), col); - p.x++; - } - p.y++; - } -} diff --git a/stdme/src/blx/draw/draw_string.c b/stdme/src/blx/draw/draw_string.c deleted file mode 100644 index 441f42e2..00000000 --- a/stdme/src/blx/draw/draw_string.c +++ /dev/null @@ -1,82 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* draw_string.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/27 19:02:59 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 15:31:57 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/colors.h" -#include "me/blx/sprite.h" -#include "me/types.h" -#include "me/vec2/vec2.h" -#include - -static inline void inner(t_blx *app, char c, t_vi2d pixel_pos, t_color col) -{ - t_vi2d o; - t_color texel; - t_vi2d offset; - - o.x = (c - 32) % 16; - o.y = (c - 32) / 16; - texel = new_color(0, 0, 0); - offset.y = 0; - while (offset.y < 8) - { - offset.x = 0; - while (offset.x < 8) - { - if (!sprite_get_pixel(&app->_data.font, vi2d(offset.x + o.x * 8, - offset.y + o.y * 8), &texel) && texel.a == 0) - blx_draw(app, vi2d_add(pixel_pos, offset), col); - offset.x++; - } - offset.y++; - } -} - -static inline t_draw_mode handle_draw_mode(t_blx *app, t_color col) -{ - t_draw_mode m; - - m = get_draw_mode(app); - if (col.a != 0x00) - set_draw_mode(app, ALPHA); - else - set_draw_mode(app, MASK); - return (m); -} - -void blx_draw_string(t_blx *app, t_vi2d pos, t_const_str sText, t_color col) -{ - t_vi2d s; - t_draw_mode m; - char c; - - s.x = 0; - s.y = 0; - m = handle_draw_mode(app, col); - while (*sText) - { - c = *sText++; - if (c == '\n') - { - s.x = 0; - s.y += 8; - } - else if (c == '\t') - s.x += 8 * 4; - else - { - inner(app, c, vi2d(pos.x + s.x, pos.y + s.y), col); - s.x += 8; - } - } - set_draw_mode(app, m); -} diff --git a/stdme/src/blx/inputs.c b/stdme/src/blx/inputs.c deleted file mode 100644 index 2bc0ef58..00000000 --- a/stdme/src/blx/inputs.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* inputs.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/15 16:38:08 by maiboyer #+# #+# */ -/* Updated: 2023/12/30 18:15:42 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/inputs.h" -#include "me/vec/vec_u8.h" -#include - -static t_vec_u8 alloc_input_vector(void) -{ - t_vec_u8 out; - - out = vec_u8_new(64, NULL); - while (out.len < 64) - vec_u8_push(&out, 0); - return (out); -} - -t_blx_input create_inputs_manager(t_blx *ctx) -{ - t_blx_input out; - - (void)(ctx); - out = (t_blx_input){ - .mouse = 0, - .keysyms_held = alloc_input_vector(), - .keysyms_pressed = alloc_input_vector(), - .keysyms_released = alloc_input_vector(), - }; - return (out); -} diff --git a/stdme/src/blx/logic.c b/stdme/src/blx/logic.c deleted file mode 100644 index 64bbf665..00000000 --- a/stdme/src/blx/logic.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* logic.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/15 18:06:06 by maiboyer #+# #+# */ -/* Updated: 2023/12/25 18:33:12 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/blx_key.h" -#include "me/blx/sprite.h" -#include "me/blx/inputs.h" -#include "mlx.h" -#include -#include - -static void blx_stop(t_blx *app) -{ - mlx_loop_end(app->mlx); - blx_free(*app); - exit(0); -} - -// TODO: implement mouse buttons when needed -void blx_post_func(t_blx *ctx) -{ - t_usize idx; - - idx = 0; - while (idx < ctx->inputs.keysyms_pressed.len - && idx < ctx->inputs.keysyms_held.len) - { - ctx->inputs.keysyms_held.buffer[idx] |= \ - ctx->inputs.keysyms_pressed.buffer[idx]; - ctx->inputs.keysyms_pressed.buffer[idx] = 0; - idx++; - } - idx = 0; - while (idx < ctx->inputs.keysyms_pressed.len) - ctx->inputs.keysyms_pressed.buffer[idx++] = 0; - idx = 0; - while (idx < ctx->inputs.keysyms_released.len) - ctx->inputs.keysyms_released.buffer[idx++] = 0; -} - -int blx_loop_func(t_blx *ctx) -{ - mlx_put_image_to_window(ctx->mlx, ctx->win, ctx->_data.screen.img, 0, 0); - if (ctx->_data.exit || ctx->func(ctx)) - { - blx_stop(ctx); - return (0); - } - blx_post_func(ctx); - return (0); -} diff --git a/stdme/src/blx/sprite/draw_image.c b/stdme/src/blx/sprite/draw_image.c deleted file mode 100644 index e02a5b9c..00000000 --- a/stdme/src/blx/sprite/draw_image.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* draw_image.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 22:43:04 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 15:20:24 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/colors.h" -#include "me/blx/sprite.h" -#include - -void blx_draw_sprite_raw(t_blx *ctx, t_vi2d pos, t_sprite *img) -{ - mlx_put_image_to_window(ctx->mlx, ctx->win, img->img, pos.x, pos.y); -} diff --git a/stdme/src/blx/sprite/draw_pixel_onto.c b/stdme/src/blx/sprite/draw_pixel_onto.c deleted file mode 100644 index 507bd4f9..00000000 --- a/stdme/src/blx/sprite/draw_pixel_onto.c +++ /dev/null @@ -1,78 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* draw_pixel_onto.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/23 16:32:19 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 15:21:33 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/sprite.h" -#include -#include - -void sprite_draw_other_bpp(t_sprite *spr, t_vi2d pos, t_color col) -{ - (void)(spr); - (void)(pos); - (void)(col); - return ; -} - -void sprite_draw(t_sprite *spr, t_vi2d pos, t_color col) -{ - t_u8 *addr; - - if (!(pos.x >= 0 && pos.x < spr->width && pos.y >= 0 - && pos.y < spr->height)) - return ; - if (spr->bpp != 32) - return (sprite_draw_other_bpp(spr, pos, col)); - addr = &(spr->data)[pos.y * spr->line_size + pos.x * 4]; - if (!spr->big_endian) - { - addr[0] = col.b; - addr[1] = col.g; - addr[2] = col.r; - addr[3] = col.a; - } - else - { - addr[0] = col.a; - addr[1] = col.r; - addr[2] = col.g; - addr[3] = col.b; - } -} - -/* - addr = &(img->data)[y * img->line_size + (x << 2)]; - if (!img->big_endian) - out = ((unsigned long)addr[0] << 24 | (unsigned long)addr[1] << 16 | - (unsigned long)addr[2] << 8 | addr[3]); - else - out = ((unsigned long)addr[3] << 24 | (unsigned long)addr[2] << 16 | - (unsigned long)addr[1] << 8 | addr[0]); - return (out); -*/ - -void sprite_clear(t_sprite *img, t_color col) -{ - t_vi2d pos; - - pos.y = 0; - while (pos.y < img->height) - { - pos.x = 0; - while (pos.x < img->width) - { - sprite_draw(img, pos, col); - pos.x++; - } - pos.y++; - } -} diff --git a/stdme/src/blx/sprite/draw_string.c b/stdme/src/blx/sprite/draw_string.c deleted file mode 100644 index a2076546..00000000 --- a/stdme/src/blx/sprite/draw_string.c +++ /dev/null @@ -1,82 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* draw_string.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboxy[1]er +#+ +:+ +#+ - */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/27 18:29:56 by maiboxy[1]er #+# #+# */ -/* Updated: 2023/12/27 18:43:57 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/colors.h" -#include "me/blx/sprite.h" -#include "me/types.h" - -static inline void inner(t_sprite *spr, char c, t_vi2d pixel_pos, t_color col) -{ - t_vi2d o; - t_color texel; - t_vi2d offset; - - o.x = (c - 32) % 16; - o.y = (c - 32) / 16; - texel = new_color(0, 0, 0); - offset.y = 0; - while (offset.y < 8) - { - offset.x = 0; - while (offset.x < 8) - { - if (!sprite_get_pixel(&spr->ctx->_data.font, vi2d(offset.x + o.x - * 8, offset.y + o.y * 8), &texel) && texel.a == 0) - sprite_draw(spr, vi2d_add(pixel_pos, offset), col); - offset.x++; - } - offset.y++; - } -} - -static inline t_draw_mode handle_draw_mode(t_blx *app, t_color col) -{ - t_draw_mode m; - - m = get_draw_mode(app); - if (col.a != 0x00) - set_draw_mode(app, ALPHA); - else - set_draw_mode(app, MASK); - return (m); -} - -void sprite_draw_string(t_sprite *spr, t_vi2d pos, t_const_str sText, - t_color col) -{ - t_vi2d s; - t_draw_mode m; - char c; - - s.x = 0; - s.y = 0; - m = handle_draw_mode(spr->ctx, col); - while (*sText) - { - c = *sText++; - if (c == '\n') - { - s.x = 0; - s.y += 8; - } - else if (c == '\t') - s.x += 8 * 4; - else - { - inner(spr, c, vi2d(pos.x + s.x, pos.y + s.y), col); - s.x += 8; - } - } - set_draw_mode(spr->ctx, m); -} diff --git a/stdme/src/blx/sprite/free_image.c b/stdme/src/blx/sprite/free_image.c deleted file mode 100644 index a3416dd0..00000000 --- a/stdme/src/blx/sprite/free_image.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* free_image.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 22:40:12 by maiboyer #+# #+# */ -/* Updated: 2023/12/26 15:39:04 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/sprite.h" -#include - -void blx_sprite_free(t_sprite img) -{ - mlx_destroy_image(img.ctx->mlx, img.img); -} diff --git a/stdme/src/blx/sprite/get_pixel.c b/stdme/src/blx/sprite/get_pixel.c deleted file mode 100644 index e74fe3f2..00000000 --- a/stdme/src/blx/sprite/get_pixel.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* get_pixel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/24 00:48:23 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 15:27:55 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/colors.h" -#include "me/blx/sprite.h" - -static bool sprite_get_pixel_other_bpp(t_sprite *spr, t_vi2d pos, t_color *out) -{ - (void)(spr); - (void)(pos); - (void)(out); - return (true); -} - -bool sprite_get_pixel(t_sprite *spr, t_vi2d pos, t_color *out) -{ - t_u8 *addr; - t_color col; - - if (!(pos.x >= 0 && pos.x < spr->width && pos.y >= 0 - && pos.y < spr->height)) - return (true); - if (spr->bpp != 32) - return (sprite_get_pixel_other_bpp(spr, pos, out)); - addr = &(spr->data)[pos.y * spr->line_size + pos.x * 4]; - if (spr->big_endian) - { - col.a = addr[0]; - col.r = addr[1]; - col.g = addr[2]; - col.b = addr[3]; - } - else - { - col.a = addr[3]; - col.r = addr[2]; - col.g = addr[1]; - col.b = addr[0]; - } - *out = col; - return (false); -} diff --git a/stdme/src/blx/sprite/new_image.c b/stdme/src/blx/sprite/new_image.c deleted file mode 100644 index 130422f6..00000000 --- a/stdme/src/blx/sprite/new_image.c +++ /dev/null @@ -1,56 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* new_image.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/21 21:59:04 by maiboyer #+# #+# */ -/* Updated: 2023/12/26 15:40:08 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/colors.h" -#include "me/blx/sprite.h" -#include - -bool blx_sprite_from_xpm(t_blx *ctx, t_str path, t_sprite *out) -{ - t_sprite spr; - t_i32 bpp; - t_i32 size_line; - t_i32 endian; - - spr.ctx = ctx; - spr.img = mlx_xpm_file_to_image(ctx->mlx, path, &spr.width, &spr.height); - if (spr.img == NULL) - return (false); - spr.data = (t_u8 *)mlx_get_data_addr(spr.img, &bpp, &size_line, &endian); - spr.bpp = bpp; - spr.line_size = (t_usize)size_line; - spr.big_endian = endian == 1; - *out = spr; - return (true); -} - -bool blx_sprite_new(t_blx *ctx, t_i32 width, t_i32 height, t_sprite *out) -{ - t_sprite spr; - t_i32 bpp; - t_i32 size_line; - t_i32 endian; - - spr.ctx = ctx; - spr.img = mlx_new_image(ctx->mlx, width, height); - if (spr.img == NULL) - return (false); - spr.data = (t_u8 *)mlx_get_data_addr(spr.img, &bpp, &size_line, &endian); - spr.bpp = bpp; - spr.line_size = (t_usize)size_line; - spr.big_endian = endian == 1; - spr.width = width; - spr.height = height; - *out = spr; - return (true); -} diff --git a/stdme/src/blx/sprite/sprite_draw_onto_sprite.c b/stdme/src/blx/sprite/sprite_draw_onto_sprite.c deleted file mode 100644 index 7590b4e0..00000000 --- a/stdme/src/blx/sprite/sprite_draw_onto_sprite.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* sprite_draw_onto_sprite.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/26 19:33:22 by maiboyer #+# #+# */ -/* Updated: 2023/12/31 15:26:41 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/blx/blx.h" -#include "me/blx/colors.h" -#include "me/blx/sprite.h" -#include "me/types.h" -#include "me/vec2/vec2.h" - -void sprite_draw_onto(t_sprite *dest, t_vi2d pos, t_sprite *source) -{ - t_vi2d p; - t_color col; - - p.y = 0; - while (p.y < source->height) - { - p.x = 0; - while (p.x < source->width) - { - sprite_get_pixel(source, p, &col); - sprite_draw(dest, vi2d_add(pos, p), col); - p.x++; - } - p.y++; - } -} diff --git a/symdif.py b/symdif.py index a8f0ab29..10b1aae5 100755 --- a/symdif.py +++ b/symdif.py @@ -47,8 +47,8 @@ for line in dump_binary.stdout.split('\n'): if (len (words) >= 8 and words[3] == 'FUNC'): symbols_binary.add(words[7]) -#diff = list(symbols_archive - symbols_binary) -diff = list(symbols_binary - symbols_archive) +diff = list(symbols_archive - symbols_binary) +#diff = list(symbols_binary - symbols_archive) diff.sort() for sym in diff: print(f"{sym}")