From 8a00ab5a6b67f3dd0d8244f3556648b30ea6fe0b Mon Sep 17 00:00:00 2001 From: Thomas Touhey Date: Mon, 23 May 2016 23:56:02 +0200 Subject: [PATCH] Added ML_background --- Makefile.vars | 7 +++++-- include/monochrome.h | 13 ++++++++++++- src/ML_background.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/ML_vram_adress.c | 2 +- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 src/ML_background.c diff --git a/Makefile.vars b/Makefile.vars index 96bad2a..d757b94 100644 --- a/Makefile.vars +++ b/Makefile.vars @@ -35,7 +35,9 @@ SRC = ML_vram_adress \ ML_bmp_8_or ML_bmp_8_and ML_bmp_8_xor \ ML_bmp_8_or_cl ML_bmp_8_and_cl ML_bmp_8_xor_cl \ ML_bmp_16_or ML_bmp_16_and ML_bmp_16_xor \ - ML_bmp_16_or_cl ML_bmp_16_and_cl ML_bmp_16_xor_cl + ML_bmp_16_or_cl ML_bmp_16_and_cl ML_bmp_16_xor_cl \ + \ + ML_background # INCLUDE FILES ## PUBLIC @@ -65,7 +67,8 @@ MAN = $(MAN3:%=man3/%.3) PLATFORM = sh3eb-elf- ## Compilator CC = $(PLATFORM)gcc -CFLAGS = -I $(INCDIR) +CHKFLAGS = -Wall -Wextra +CFLAGS = -I $(INCDIR) $(CHKFLAGS) ## Archive manager AR = $(PLATFORM)ar ## Ranlib diff --git a/include/monochrome.h b/include/monochrome.h index 675f0ef..0b8e3ee 100644 --- a/include/monochrome.h +++ b/include/monochrome.h @@ -29,11 +29,17 @@ typedef enum { ML_CHECKER } ML_Color; +typedef enum { + ML_MOR, + ML_MAND, + ML_MXOR +} ML_Mode; + /* ** Function prototypes */ -char* ML_vram_adress(); +void* ML_vram_adress(); void ML_clear_vram(); void ML_clear_screen(); @@ -87,6 +93,11 @@ void ML_bmp_16_or_cl(const unsigned short *bmp, int x, int y); void ML_bmp_16_and_cl(const unsigned short *bmp, int x, int y); void ML_bmp_16_xor_cl(const unsigned short *bmp, int x, int y); +#define ML_background_or(B) ML_background((B), ML_OR) +#define ML_background_and(B) ML_background((B), ML_AND) +#define ML_background_xor(B) ML_background((B), ML_XOR) +void ML_background(const void *bmp, ML_Mode mode); + # ifdef __cplusplus } # endif diff --git a/src/ML_background.c b/src/ML_background.c new file mode 100644 index 0000000..697ce2d --- /dev/null +++ b/src/ML_background.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* _____ _ */ +/* ML_background.c |_ _|__ _ _| |__ ___ _ _ */ +/* | Project : CaphiOS | |/ _ \| | | | '_ \ / _ \ | | | */ +/* | | (_) | |_| | | | | __/ |_| | */ +/* By: thomas |_|\___/ \__,_|_| |_|\___|\__, |.fr */ +/* Last updated: 2016/05/23 23:38:59 |___/ */ +/* */ +/* ************************************************************************** */ + +#include + +/* +** ML_background: +** Draws a sprite on the whole screen. +** @bmp: link to the bmp data (must be 128*16 bytes long) +*/ + +void ML_background(const void *bmp, ML_Mode mode) +{ + unsigned int *v = ML_vram_adress(); + const unsigned int *b = bmp; + int w = 0; + + switch (mode) { + case ML_MAND: + for (; w < 256; w++, v++, b++) + *v &= *b; + break; + + case ML_MOR: + for (; w < 256; w++, v++, b++) + *v |= *b; + break; + + case ML_MXOR: + for (; w < 256; w++, v++, b++) + *v ^= *b; + break; + } +} diff --git a/src/ML_vram_adress.c b/src/ML_vram_adress.c index 519a9ec..9b7b245 100644 --- a/src/ML_vram_adress.c +++ b/src/ML_vram_adress.c @@ -14,7 +14,7 @@ typedef char*(*sc_cpv)(void); const unsigned int sc0135[] = {0xD201D002, 0x422B0009, 0x80010070, 0x0135}; -char* ML_vram_adress() +void* ML_vram_adress() { return ((sc_cpv)sc0135)(); }