- [NEW] draw.mode(), amb modes NORMAL, PATTERN, AND, OR, XOR i NOT

- [NEW] Ara per a pintar en pattern hi ha que dir-ho en draw.mode(), no es automatic al ficar un pattern.
- [NEW] Nous modes de pintat booleans. AND, OR i XOR fan l'operació pixel_actual = pixel_actual OP color_especificat. NOT no usa el color especificat, nomes fa un NOT del pixel actual.
This commit is contained in:
2026-02-24 11:03:21 +01:00
parent 9581ce67fd
commit fc962b4e18
5 changed files with 85 additions and 2 deletions

View File

@@ -78,6 +78,7 @@ namespace ds {
uint16_t fill_pattern = 0b1111111111111111;
bool fill_trans = false;
uint8_t draw_palette[256];
uint8_t mode = DRAWMODE_NORMAL;
}
int update_mode = UPDATE_ALWAYS;
@@ -163,6 +164,25 @@ void pset_fast(int x, int y) {
if (ds::trans != ds::pen_color) DEST(x, y) = ds::draw_palette[ds::pen_color];
}
void pset_bool(int x, int y) {
if (ds::trans != ds::pen_color) {
switch (ds::mode) {
case DRAWMODE_AND:
DEST(x, y) = DEST(x, y) & ds::draw_palette[ds::pen_color];
break;
case DRAWMODE_OR:
DEST(x, y) = DEST(x, y) | ds::draw_palette[ds::pen_color];
break;
case DRAWMODE_XOR:
DEST(x, y) = DEST(x, y) ^ ds::draw_palette[ds::pen_color];
break;
case DRAWMODE_NOT:
DEST(x, y) = ~DEST(x, y);
break;
}
}
}
void pset_pattern(int x, int y) {
int pbx = x % 4, pby = y % 4;
int pb = pbx+pby*4;
@@ -173,6 +193,27 @@ void pset_pattern(int x, int y) {
}
}
void set_draw_mode(uint8_t mode) {
ds::mode = mode;
switch (mode) {
case DRAWMODE_NORMAL:
do_pset = pset_fast;
break;
case DRAWMODE_PATTERN:
do_pset = pset_pattern;
break;
case DRAWMODE_AND:
case DRAWMODE_OR:
case DRAWMODE_XOR:
case DRAWMODE_NOT:
do_pset = pset_bool;
break;
default:
do_pset = pset_fast;
break;
}
}
void reinit() {
log_msg(LOG_INFO, "STARTING A SYSTEM REINITIALIZATION\n");
do_pset = pset_fast;
@@ -816,7 +857,6 @@ void rectfill(int x, int y, int w, int h, uint8_t color) {
void fillp(uint16_t pat, bool transparent) {
ds::fill_trans = true; //transparent;
ds::fill_pattern = pat;
do_pset=(pat==0xffff?pset_fast:pset_pattern);
}
void print_symbol(char sym, int x, int y) {