From bcbab0342a226aaabba11ef4a5b1bdda8b6238ac Mon Sep 17 00:00:00 2001 From: milang Date: Thu, 29 Aug 2019 14:07:02 +0200 Subject: [PATCH] configure bitmaps and correct makefile --- Makefile | 10 +++-- build/src/render/zbuffer.c.o | Bin 768 -> 928 bytes include/render/bitmap.h | 71 ++++++++++++++++++----------------- libfxengine.a | Bin 5042 -> 6082 bytes src/render/bitmap.c | 36 ++++++++---------- 5 files changed, 58 insertions(+), 59 deletions(-) diff --git a/Makefile b/Makefile index 36f0451..6c3de0b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ target ?= sh3eb-elf cflags := -m3 -mb -D FX9860G -ffreestanding -nostdlib -fstrict-volatile-bitfields -Wall \ - -Wextra -Os -I . + -Wextra -Os -Iinclude -I . lib := libfxengine.a header := include/ @@ -31,15 +31,19 @@ build/%.c.o: %.c @ mkdir -p $(dir $@) $(target)-gcc -c $< -o $@ $(cflags) -clear: +clean: @ rm -rf build @ rm -f $(lib) %/: mkdir -p $@ +reinstall: + @ make clean + @ make + @ make install install: sh3eb-elf-ar -t $(lib) cp $(lib) $(prefix) - cp -r $(header) $(prefix)include/fxengine \ No newline at end of file + cp -r $(header) $(prefix)/include/fxengine diff --git a/build/src/render/zbuffer.c.o b/build/src/render/zbuffer.c.o index cc01f0ef7feb96be73f450a557572567316f2022..94e41bf9b4c31a950c3d21c85ac7789091007be4 100644 GIT binary patch delta 477 zcmZo*Tfja+DT&E~fq{XU!30P$FlaDvGH_hr_g8Y@X5dud=oNg%aFKVC$aC(;I}(x` z1QUuIgc6Ju6PyGZg!{i0viPep0M%V%oyu~B`68>Mw!fMJ1NRP)K^^S%{}~t>Kum^- zF`FmLGm5x^IUs_Wfq@lBaYF?HgcukYfow%6pFse^&_LsZoER|KgHcN`vpCqpm?1tT zH!(gpHMcmmWO4zcq&QI8fq{V?WE2SaFfed{*pu5CWm$?+a}p;nW^_+f0E&P_*?<@X zK!$DrvmgWulr0UUL2L&IpYaKhmH=XqK9GKp91jqyLHR&Gfx(l>K1|Z496&Z)1S$ig zVD2*n3V_%KP>Cm#OPJJke*k$4fS4VKL3V-c0fh%A5W`FaG8tz83Gc}#n3P5T09jT* I3-?{n_QI}(x`1QUuIgc6Ju6PyGZ zg!{i0vM_Kna4Il#u-E^e*s__CX|e{RvM4uLGf=w_0|O(Ftq3w|@&rb$$!8hGC;w%X zo-E7cR?i>}6b4DN0Wk=G?Cb!uAOs7P4bl!$#|-7~fzmJvBnJZOK+FNegw*K()i46x z&0qjzfWV%~BFyT#7l5n=AO<-HghAE|05K;J!;Azn83TZX#pDcTWl@l0O@SB&zzzWb D4Mig+ diff --git a/include/render/bitmap.h b/include/render/bitmap.h index a5afb4b..b65d66c 100644 --- a/include/render/bitmap.h +++ b/include/render/bitmap.h @@ -5,46 +5,47 @@ 0 dans layout -> transparent 1 dans layout -> 1 dans color -> noir 0 dans color -> blanc */ - -struct bitmap_rich_8 +/** bitmap rich type +* @warning Monochrome only ! +* transparency is in the layout +*/ +struct bitmap_rich { - uint32_t size_px_x; // largeur en pixels - uint32_t size_px_y; // hauteur en pixels - uint32_t size_o_y; // taille en octets d'une rangée + uint32_t size_px_x; + uint32_t size_px_y; + uint32_t size_o_y; - uint8_t * color; // bitmap monochrome - uint8_t * layout; // transparence + uint32_t * color; + uint32_t * layout; }; -typedef struct bitmap_rich_16 bitmap_rich_16; +typedef struct bitmap_rich bitmap_rich; -struct bitmap_rich_16 -{ - uint32_t size_px_x; - uint32_t size_px_y; - uint32_t size_o_y; +/** get the color of pixel from rich bitmap +* @return the color coded in a unsigned char : +* if (color >> 1) +* switch (color%2) +* { +* case 0: +* // WHITE +* break; +* case 1: +* // BLACK +* } +* else +* // TRANSPARENT +* @param the bitmap +* @param x coordinate +* @param y coordinate +*/ +inline uint8_t bitmap_get_pixel_r(const bitmap_rich * bmp, uint32_t x, uint32_t y); - uint16_t * color; - uint16_t * layout; -}; -typedef struct bitmap_rich_16 bitmap_rich_16; - -struct bitmap_rich_32 -{ - uint32_t size_px_x; - uint32_t size_px_y; - uint32_t size_o_y; - - uint32_t * color; - uint32_t * layout; -}; -typedef struct bitmap_rich_32 bitmap_rich_32; +/** display a pixel from rich bitmap +* // TRANSPARENT +* @param the bitmap +* @param x coordinate +* @param y coordinate +*/ +void bitmap_display_pixel_r(const bitmap_rich * bmp, uint32_t bmp_x, uint32_t bmp_y, uint32_t x, uint32_t y); -/* bitmap_get_color_(int x, int y) - returns a color coded in 2 bytes - byte 7 -> layout (visible, invisible) - byte 6 -> color (N || B) */ -inline uint8_t bitmap_get_color_8(const bitmap_rich_8 * bmp,uint32_t x, uint32_t y); -inline uint8_t bitmap_get_color_16(const bitmap_rich_16 * bmp,uint32_t x, uint32_t y); -inline uint8_t bitmap_get_color_32(const bitmap_rich_32 * bmp,uint32_t x, uint32_t y); \ No newline at end of file diff --git a/libfxengine.a b/libfxengine.a index bc449350cbdbcd02e1be50db95eb658b067bdba9..259779f0fbaf343ac53c7f13fde65a84d7db218e 100644 GIT binary patch delta 862 zcmdm_en@|UG@H4Bg@LifL`4Z_V+#ccNZ?{%VBlq7U^IeYmU|2g96&ZcEc}dtLHOCk z3N5ju%#z&1g7}oo;)0yS%J_oJiqxF=qKOMSg&|fMDkvC$?E#USZ5Z2_jUig}lJ)ZS z!7_%XW?0lJC>R!NAGDq2G3aPk)-fk^^@} zaU!!LV-j0tmPW0fPZZD}i}HLIA=rL*c{xzz~l;0N~>3sU@&LVTexw2M@#`8wLh; zkUb#a0JM^0@?1Xi$pOrsj4qRBF)Opi0L3LHA7WN!teE^yNP2QFKQ|Kth$%i*E%R+7iyrFJsWHH&3 zQAgPVXdFtYU*HFYI0L5wN3Y;BhKszDL?*uxkWlkiV*mkSH1F~&bYrWFvw05}c-O6ssA delta 447 zcmX@4ze#<9G@F^FrMao$L`4aELjwf}NZ?{%VBle3U=)L3mO~5-_^?131A{=> +#include +#include -inline uint8_t bitmap_get_color_8(const bitmap_rich_8 * bmp, uint32_t x, uint32_t y) +inline uint8_t bitmap_get_pixel_r(const bitmap_rich * bmp, uint32_t x, uint32_t y) { - if (x >= bmp->size_px_x || y >= bmp->size_px_y) - const uint32_t indice = y * bmp.size_o_y + x >> 3; - const uint32_t numero_bit = 7 - x % 8; + if (x >= bmp->size_px_x || y >= bmp->size_px_y) + return 0; - return ( bmp.layout[indice] | 1 << numero_bit ) << 1 + ( bmp.color[indice] | 1 << numero_bit ); + const uint32_t indice = y * bmp->size_o_y + x >> 5; + + const uint32_t numero_bit = 31 - x % 32; + + return ( bmp->layout[indice] | 1 << numero_bit ) << 1 + ( bmp->color[indice] | 1 << numero_bit ); } -inline uint8_t bitmap_get_color_16(const bitmap_rich_16 * bmp, uint32_t x, uint32_t y) -{ - if (x >= bmp->size_px_x || y >= bmp->size_px_y) - const uint32_t indice = y * bmp.size_o_y + x >> 4; - const uint32_t numero_bit = 15 - x % 16; - return ( bmp.layout[indice] | 1 << numero_bit ) << 1 + ( bmp.color[indice] | 1 << numero_bit ); +void bitmap_display_pixel_r(const bitmap_rich * bmp, uint32_t bmp_x, uint32_t bmp_y, uint32_t x, uint32_t y) +{ + uint8_t color = bitmap_get_pixel_r(bmp, bmp_x, bmp_y); + if (color >> 1) + dpixel(x, y, 3 * (color % 2)); } - -inline uint8_t bitmap_get_color_32(const bitmap_rich_32 * bmp, uint32_t x, uint32_t y) -{ - if (x >= bmp->size_px_x || y >= bmp->size_px_y) - const uint32_t indice = y * bmp.size_o_y + x >> 5; - const uint32_t numero_bit = 31 - x % 32; - - return ( bmp.layout[indice] | 1 << numero_bit ) << 1 + ( bmp.color[indice] | 1 << numero_bit ); -} \ No newline at end of file