- [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:
15
lua.cpp
15
lua.cpp
@@ -578,6 +578,12 @@ extern "C" {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_draw_mode(lua_State *L) {
|
||||||
|
int mode = luaL_checknumber(L, 1);
|
||||||
|
set_draw_mode(mode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// shaders
|
// shaders
|
||||||
// ===============================================
|
// ===============================================
|
||||||
@@ -1032,6 +1038,15 @@ void push_lua_funcs() {
|
|||||||
lua_pushcfunction(L,cpp_draw_surface); lua_setfield(L, -2, "surf");
|
lua_pushcfunction(L,cpp_draw_surface); lua_setfield(L, -2, "surf");
|
||||||
lua_pushcfunction(L,cpp_draw_surfaceRotated); lua_setfield(L, -2, "surfrot");
|
lua_pushcfunction(L,cpp_draw_surfaceRotated); lua_setfield(L, -2, "surfrot");
|
||||||
lua_pushcfunction(L,cpp_draw_text); lua_setfield(L, -2, "text");
|
lua_pushcfunction(L,cpp_draw_text); lua_setfield(L, -2, "text");
|
||||||
|
lua_pushcfunction(L,cpp_draw_mode); lua_setfield(L, -2, "mode");
|
||||||
|
|
||||||
|
lua_pushinteger(L, 0); lua_setfield(L, -2, "NORMAL");
|
||||||
|
lua_pushinteger(L, 1); lua_setfield(L, -2, "PATTERN");
|
||||||
|
lua_pushinteger(L, 2); lua_setfield(L, -2, "AND");
|
||||||
|
lua_pushinteger(L, 3); lua_setfield(L, -2, "OR");
|
||||||
|
lua_pushinteger(L, 4); lua_setfield(L, -2, "XOR");
|
||||||
|
lua_pushinteger(L, 5); lua_setfield(L, -2, "NOT");
|
||||||
|
|
||||||
lua_setglobal(L, "draw");
|
lua_setglobal(L, "draw");
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|||||||
42
mini.cpp
42
mini.cpp
@@ -78,6 +78,7 @@ namespace ds {
|
|||||||
uint16_t fill_pattern = 0b1111111111111111;
|
uint16_t fill_pattern = 0b1111111111111111;
|
||||||
bool fill_trans = false;
|
bool fill_trans = false;
|
||||||
uint8_t draw_palette[256];
|
uint8_t draw_palette[256];
|
||||||
|
uint8_t mode = DRAWMODE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int update_mode = UPDATE_ALWAYS;
|
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];
|
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) {
|
void pset_pattern(int x, int y) {
|
||||||
int pbx = x % 4, pby = y % 4;
|
int pbx = x % 4, pby = y % 4;
|
||||||
int pb = pbx+pby*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() {
|
void reinit() {
|
||||||
log_msg(LOG_INFO, "STARTING A SYSTEM REINITIALIZATION\n");
|
log_msg(LOG_INFO, "STARTING A SYSTEM REINITIALIZATION\n");
|
||||||
do_pset = pset_fast;
|
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) {
|
void fillp(uint16_t pat, bool transparent) {
|
||||||
ds::fill_trans = true; //transparent;
|
ds::fill_trans = true; //transparent;
|
||||||
ds::fill_pattern = pat;
|
ds::fill_pattern = pat;
|
||||||
do_pset=(pat==0xffff?pset_fast:pset_pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_symbol(char sym, int x, int y) {
|
void print_symbol(char sym, int x, int y) {
|
||||||
|
|||||||
8
mini.h
8
mini.h
@@ -112,6 +112,13 @@
|
|||||||
#define KEY_RALT 230
|
#define KEY_RALT 230
|
||||||
#define KEY_RGUI 231
|
#define KEY_RGUI 231
|
||||||
|
|
||||||
|
#define DRAWMODE_NORMAL 0
|
||||||
|
#define DRAWMODE_PATTERN 1
|
||||||
|
#define DRAWMODE_AND 2
|
||||||
|
#define DRAWMODE_OR 3
|
||||||
|
#define DRAWMODE_XOR 4
|
||||||
|
#define DRAWMODE_NOT 5
|
||||||
|
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
int scrw();
|
int scrw();
|
||||||
@@ -146,6 +153,7 @@ uint8_t gettrans();
|
|||||||
void subpal(uint8_t index, uint8_t color);
|
void subpal(uint8_t index, uint8_t color);
|
||||||
void reset_subpal();
|
void reset_subpal();
|
||||||
|
|
||||||
|
void set_draw_mode(uint8_t mode);
|
||||||
void pset(int x, int y);
|
void pset(int x, int y);
|
||||||
void pset(int x, int y, uint8_t color);
|
void pset(int x, int y, uint8_t color);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MINI_VERSION "1.3.14"
|
#define MINI_VERSION "1.3.15"
|
||||||
|
|||||||
@@ -164,7 +164,15 @@ function view.origin(x, y) end
|
|||||||
---Convert screen position to viewport position
|
---Convert screen position to viewport position
|
||||||
function view.tolocal(x, y) end
|
function view.tolocal(x, y) end
|
||||||
|
|
||||||
|
|
||||||
---@class draw
|
---@class draw
|
||||||
|
---@field draw.NORMAL number
|
||||||
|
---@field draw.PATTERN number
|
||||||
|
---@field draw.AND number
|
||||||
|
---@field draw.OR number
|
||||||
|
---@field draw.XOR number
|
||||||
|
---@field draw.NOT number
|
||||||
|
|
||||||
draw = {}
|
draw = {}
|
||||||
|
|
||||||
---@param x1 number
|
---@param x1 number
|
||||||
@@ -301,6 +309,18 @@ function draw.text(text, x, y, color) end
|
|||||||
---Draw text to (x,y) using the specified color
|
---Draw text to (x,y) using the specified color
|
||||||
function draw.text(text, x, y, color) end
|
function draw.text(text, x, y, color) end
|
||||||
|
|
||||||
|
---@param mode number
|
||||||
|
---Specify the mode for the drawing functions
|
||||||
|
function draw.mode(mode) end
|
||||||
|
|
||||||
|
draw.NORMAL = 0
|
||||||
|
draw.PATTERN = 1
|
||||||
|
draw.AND = 2
|
||||||
|
draw.OR = 3
|
||||||
|
draw.XOR = 4
|
||||||
|
draw.NOT = 5
|
||||||
|
|
||||||
|
|
||||||
---@class shader
|
---@class shader
|
||||||
shader = {}
|
shader = {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user