From 7fd30e7d2067bc0d94a57bd44519a59469a9f08b Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 3 Feb 2020 16:46:14 -0800 Subject: [PATCH 01/15] First draft of eveL, the low-level module of the Gameduino (and BridgeTek EVE) bindings. [adafruit/circuitpython#2578] --- .../boards/metro_m4_express/mpconfigboard.mk | 2 + .../metro_nrf52840_express/mpconfigboard.mk | 2 + py/circuitpy_defns.mk | 4 + py/circuitpy_mpconfig.h | 8 + py/circuitpy_mpconfig.mk | 5 + shared-bindings/eveL/__init__.c | 225 ++++++++++ shared-bindings/eveL/modeveL-gen.h | 412 ++++++++++++++++++ 7 files changed, 658 insertions(+) create mode 100644 shared-bindings/eveL/__init__.c create mode 100644 shared-bindings/eveL/modeveL-gen.h diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk index 62e6b7c72f8c..d4593f83a594 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk @@ -10,3 +10,5 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ + +CIRCUITPY_EVEL = 1 diff --git a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk index d421e5210474..ade77f0765df 100644 --- a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk +++ b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk @@ -8,3 +8,5 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "GD25Q16C" + +CIRCUITPY_EVEL = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 1f2d6c73ef25..859d3837b106 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -157,6 +157,9 @@ endif ifeq ($(CIRCUITPY_MATH),1) SRC_PATTERNS += math/% endif +ifeq ($(CIRCUITPY_EVEL),1) +SRC_PATTERNS += eveL/% +endif ifeq ($(CIRCUITPY_MICROCONTROLLER),1) SRC_PATTERNS += microcontroller/% endif @@ -298,6 +301,7 @@ $(filter $(SRC_PATTERNS), \ fontio/Glyph.c \ microcontroller/RunMode.c \ math/__init__.c \ + eveL/__init__.c \ ) SRC_BINDINGS_ENUMS += \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 5b705a0883df..8b7ac46b0420 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -384,6 +384,13 @@ extern const struct _mp_obj_module_t math_module; #define MATH_MODULE #endif +#if CIRCUITPY_EVEL +extern const struct _mp_obj_module_t eveL_module; +#define EVEL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_eveL), (mp_obj_t)&eveL_module }, +#else +#define EVEL_MODULE +#endif + #if CIRCUITPY_MICROCONTROLLER extern const struct _mp_obj_module_t microcontroller_module; #define MICROCONTROLLER_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, @@ -617,6 +624,7 @@ extern const struct _mp_obj_module_t ustack_module; I2CSLAVE_MODULE \ JSON_MODULE \ MATH_MODULE \ + EVEL_MODULE \ MICROCONTROLLER_MODULE \ NEOPIXEL_WRITE_MODULE \ NETWORK_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 93175e136f66..f56d994789f6 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -174,6 +174,11 @@ CIRCUITPY_MATH = $(CIRCUITPY_ALWAYS_BUILD) endif CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) +ifndef CIRCUITPY_EVEL +CIRCUITPY_EVEL = $(CIRCUITPY_ALWAYS_BUILD) +endif +CFLAGS += -DCIRCUITPY_EVEL=$(CIRCUITPY_EVEL) + ifndef CIRCUITPY_MICROCONTROLLER CIRCUITPY_MICROCONTROLLER = $(CIRCUITPY_DEFAULT_BUILD) endif diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c new file mode 100644 index 000000000000..3bbffa257f75 --- /dev/null +++ b/shared-bindings/eveL/__init__.c @@ -0,0 +1,225 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Paul Sokolovsky + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include + +#include "py/runtime.h" +#include "py/binary.h" + +// #if MICROPY_PY_BUILTINS_EVEL + +typedef struct _mp_obj_EVEL_t { + mp_obj_base_t base; + mp_obj_t writer; + mp_obj_t dest[3]; + + size_t n; + uint8_t buf[512]; +} mp_obj_EVEL_t; + +STATIC void _write(mp_obj_EVEL_t *EVEL, mp_obj_t b) { + EVEL->dest[2] = b; + mp_call_method_n_kw(1, 0, EVEL->dest); +} + +STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { + mp_obj_EVEL_t *EVEL = self; + EVEL->n = 0; + mp_printf(&mp_plat_print, "register %p %d\n", EVEL, EVEL->n); + mp_load_method(o, MP_QSTR_write, EVEL->dest); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); + +STATIC mp_obj_t _flush(mp_obj_t self) { + mp_obj_EVEL_t *EVEL = self; + // mp_printf(&mp_plat_print, "flush %p %d\n", EVEL, EVEL->n); + if (EVEL->n != 0) { + _write(EVEL, mp_obj_new_bytearray_by_ref(EVEL->n, EVEL->buf)); + EVEL->n = 0; + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); + +STATIC void *append(mp_obj_EVEL_t *EVEL, size_t m) { + if ((EVEL->n + m) > sizeof(EVEL->buf)) + _flush((mp_obj_t)EVEL); + uint8_t *r = EVEL->buf + EVEL->n; + EVEL->n += m; + return (void*)r; +} + +STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { + mp_obj_EVEL_t *EVEL = self; + mp_buffer_info_t buffer_info; + mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); + // mp_printf(&mp_plat_print, "flush %p %d %p\n", EVEL, buffer_info.len, EVEL->writer); + if (buffer_info.len <= sizeof(EVEL->buf)) { + uint8_t *p = (uint8_t*)append(EVEL, buffer_info.len); + // memcpy(p, buffer_info.buf, buffer_info.len); + uint8_t *s = buffer_info.buf; + for (size_t i = 0; i < buffer_info.len; i++) + *p++ = *s++; + } else { + _flush(self); + _write(EVEL, b); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); + +#define C4(self, u) (*(uint32_t*)append((self), sizeof(uint32_t)) = (u)) + +#include "modeveL-gen.h" + +// Hand-written functions { + +STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { + C4(self, (0xffffff00 | mp_obj_get_int_truncated(n))); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); + +STATIC mp_obj_t _vertex2f(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + int16_t x = (int16_t)(16 * mp_obj_get_float(a0)); + int16_t y = (int16_t)(16 * mp_obj_get_float(a1)); + C4(self, (0x40000000 | ((x & 32767) << 15) | (y & 32767))); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); + +STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { + mp_obj_t self = args[0]; + mp_obj_t num = args[1]; + mp_buffer_info_t fmt; + mp_get_buffer_raise(args[2], &fmt, MP_BUFFER_READ); + size_t len; + mp_obj_t *items; + mp_obj_tuple_get(args[3], &len, &items); + + // Count how many 32-bit words required + size_t n = 0; + for (size_t i = 0; i < fmt.len; n++) { + switch (((char*)fmt.buf)[i]) { + case 'I': + case 'i': + i += 1; + break; + case 'H': + case 'h': + i += 2; + break; + default: + break; + } + } + mp_printf(&mp_plat_print, "n=%d\n", n); + + uint32_t *p = (uint32_t*)append(self, sizeof(uint32_t) * (1 + n)); + *p++ = 0xffffff00 | mp_obj_get_int_truncated(num); + mp_obj_t *a = items; + uint32_t lo; + + for (size_t i = 0; i < fmt.len; ) { + switch (((char*)fmt.buf)[i]) { + case 'I': + case 'i': + *p++ = mp_obj_get_int_truncated(*a++); + mp_printf(&mp_plat_print, " %d %08x\n", p[-1]); + i += 1; + break; + case 'H': + case 'h': + lo = mp_obj_get_int_truncated(*a++) & 0xffff; + *p++ = lo | (mp_obj_get_int_truncated(*a++) << 16); + i += 2; + break; + default: + break; + } + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cmd_obj, 4, 4, _cmd); + +STATIC const mp_rom_map_elem_t EVEL_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(®ister_obj) }, + { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, + { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, + { MP_ROM_QSTR(MP_QSTR_Vertex2f), MP_ROM_PTR(&vertex2f_obj) }, + { MP_ROM_QSTR(MP_QSTR_cmd), MP_ROM_PTR(&cmd_obj) }, + { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, + ROM_DECLS +}; +STATIC MP_DEFINE_CONST_DICT(EVEL_locals_dict, EVEL_locals_dict_table); + +STATIC void EVEL_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)self_in; + (void)kind; + mp_printf(print, ""); +} + +STATIC mp_obj_t EVEL_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + // mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_obj_EVEL_t *o = m_new_obj(mp_obj_EVEL_t); + mp_printf(&mp_plat_print, "EVEL init\n"); + o->base.type = type; + return o; +} + +// STATIC void EVEL_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { +// printf("HERE\n"); +// mp_type_type.attr(self_in, attr, dest); +// printf("THERE %p %p\n", dest[0], dest[1]); +// } + +STATIC const mp_obj_type_t EVEL_type = { + { &mp_type_type }, + // Save on qstr's, reuse same as for module + .name = MP_QSTR_EVEL, + .print = EVEL_print, + .make_new = EVEL_make_new, + // .attr = EVEL_attr, + .locals_dict = (void*)&EVEL_locals_dict, +}; + +STATIC const mp_rom_map_elem_t mp_module_eveL_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_eveL) }, + { MP_ROM_QSTR(MP_QSTR_EVEL), MP_OBJ_FROM_PTR(&EVEL_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_eveL_globals, mp_module_eveL_globals_table); + +const mp_obj_module_t eveL_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_eveL_globals, +}; + +// #endif // MICROPY_PY_BUILTINS_EVEL diff --git a/shared-bindings/eveL/modeveL-gen.h b/shared-bindings/eveL/modeveL-gen.h new file mode 100644 index 000000000000..1c8d5ae12a91 --- /dev/null +++ b/shared-bindings/eveL/modeveL-gen.h @@ -0,0 +1,412 @@ + +STATIC mp_obj_t _alphafunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t func = mp_obj_get_int_truncated(a0); + uint32_t ref = mp_obj_get_int_truncated(a1); + C4(self, ((9 << 24) | ((func & 7) << 8) | ((ref & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); + +STATIC mp_obj_t _begin(mp_obj_t self , mp_obj_t a0) { + uint32_t prim = mp_obj_get_int_truncated(a0); + C4(self, ((31 << 24) | ((prim & 15))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); + +STATIC mp_obj_t _bitmapextformat(mp_obj_t self , mp_obj_t a0) { + uint32_t fmt = mp_obj_get_int_truncated(a0); + C4(self, ((46 << 24) | (fmt & 65535)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); + +STATIC mp_obj_t _bitmaphandle(mp_obj_t self , mp_obj_t a0) { + uint32_t handle = mp_obj_get_int_truncated(a0); + C4(self, ((5 << 24) | ((handle & 31))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); + +STATIC mp_obj_t _bitmaplayouth(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t linestride = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + C4(self, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); + +STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { + uint32_t format = mp_obj_get_int_truncated(args[1]); + uint32_t linestride = mp_obj_get_int_truncated(args[2]); + uint32_t height = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); + +STATIC mp_obj_t _bitmapsizeh(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + C4(self, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); + +STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { + uint32_t filter = mp_obj_get_int_truncated(args[1]); + uint32_t wrapx = mp_obj_get_int_truncated(args[2]); + uint32_t wrapy = mp_obj_get_int_truncated(args[3]); + uint32_t width = mp_obj_get_int_truncated(args[4]); + uint32_t height = mp_obj_get_int_truncated(args[5]); + C4(args[0], ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); + +STATIC mp_obj_t _bitmapsource(mp_obj_t self , mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + C4(self, ((1 << 24) | ((addr & 0xffffff))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); + +STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + C4(args[0], ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); + +STATIC mp_obj_t _bitmaptransforma(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t a = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((21 << 24) | ((p & 1) << 17) | ((a & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); + +STATIC mp_obj_t _bitmaptransformb(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t b = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((22 << 24) | ((p & 1) << 17) | ((b & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); + +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t c = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); + +STATIC mp_obj_t _bitmaptransformd(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t d = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((24 << 24) | ((p & 1) << 17) | ((d & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); + +STATIC mp_obj_t _bitmaptransforme(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t e = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((25 << 24) | ((p & 1) << 17) | ((e & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); + +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t f = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); + +STATIC mp_obj_t _blendfunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t src = mp_obj_get_int_truncated(a0); + uint32_t dst = mp_obj_get_int_truncated(a1); + C4(self, ((11 << 24) | ((src & 7) << 3) | ((dst & 7))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); + +STATIC mp_obj_t _call(mp_obj_t self , mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + C4(self, ((29 << 24) | ((dest & 65535))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); + +STATIC mp_obj_t _cell(mp_obj_t self , mp_obj_t a0) { + uint32_t cell = mp_obj_get_int_truncated(a0); + C4(self, ((6 << 24) | ((cell & 127))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); + +STATIC mp_obj_t _clearcolora(mp_obj_t self , mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + C4(self, ((15 << 24) | ((alpha & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); + +STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); + +STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { + uint32_t c = mp_obj_get_int_truncated(args[1]); + uint32_t s = mp_obj_get_int_truncated(args[2]); + uint32_t t = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 4, 4, _clear); + +STATIC mp_obj_t _clearstencil(mp_obj_t self , mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + C4(self, ((17 << 24) | ((s & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); + +STATIC mp_obj_t _cleartag(mp_obj_t self , mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + C4(self, ((18 << 24) | ((s & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); + +STATIC mp_obj_t _colora(mp_obj_t self , mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + C4(self, ((16 << 24) | ((alpha & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); + +STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + C4(args[0], ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); + +STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); + +STATIC mp_obj_t _display(mp_obj_t self ) { + + C4(self, ((0 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); + +STATIC mp_obj_t _end(mp_obj_t self ) { + + C4(self, ((33 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); + +STATIC mp_obj_t _jump(mp_obj_t self , mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + C4(self, ((30 << 24) | ((dest & 65535))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); + +STATIC mp_obj_t _linewidth(mp_obj_t self , mp_obj_t a0) { + uint32_t width = mp_obj_get_int_truncated(a0); + C4(self, ((14 << 24) | ((width & 4095))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); + +STATIC mp_obj_t _macro(mp_obj_t self , mp_obj_t a0) { + uint32_t m = mp_obj_get_int_truncated(a0); + C4(self, ((37 << 24) | ((m & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); + +STATIC mp_obj_t _nop(mp_obj_t self ) { + + C4(self, ((45 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); + +STATIC mp_obj_t _palettesource(mp_obj_t self , mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + C4(self, ((42 << 24) | (((addr) & 4194303))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); + +STATIC mp_obj_t _pointsize(mp_obj_t self , mp_obj_t a0) { + uint32_t size = mp_obj_get_int_truncated(a0); + C4(self, ((13 << 24) | ((size & 8191))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); + +STATIC mp_obj_t _restorecontext(mp_obj_t self ) { + + C4(self, ((35 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); + +STATIC mp_obj_t _return(mp_obj_t self ) { + + C4(self, ((36 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); + +STATIC mp_obj_t _savecontext(mp_obj_t self ) { + + C4(self, ((34 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); + +STATIC mp_obj_t _scissorsize(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + C4(self, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); + +STATIC mp_obj_t _scissorxy(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t x = mp_obj_get_int_truncated(a0); + uint32_t y = mp_obj_get_int_truncated(a1); + C4(self, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); + +STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { + uint32_t func = mp_obj_get_int_truncated(args[1]); + uint32_t ref = mp_obj_get_int_truncated(args[2]); + uint32_t mask = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); + +STATIC mp_obj_t _stencilmask(mp_obj_t self , mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + C4(self, ((19 << 24) | ((mask & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); + +STATIC mp_obj_t _stencilop(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t sfail = mp_obj_get_int_truncated(a0); + uint32_t spass = mp_obj_get_int_truncated(a1); + C4(self, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); + +STATIC mp_obj_t _tagmask(mp_obj_t self , mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + C4(self, ((20 << 24) | ((mask & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); + +STATIC mp_obj_t _tag(mp_obj_t self , mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + C4(self, ((3 << 24) | ((s & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); + +STATIC mp_obj_t _vertextranslatex(mp_obj_t self , mp_obj_t a0) { + uint32_t x = mp_obj_get_int_truncated(a0); + C4(self, ((43 << 24) | (((x) & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); + +STATIC mp_obj_t _vertextranslatey(mp_obj_t self , mp_obj_t a0) { + uint32_t y = mp_obj_get_int_truncated(a0); + C4(self, ((44 << 24) | (((y) & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); +#define N_METHODS 47 +#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; } while (0) +#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) } From 0bcfabbc87b3702e0bc37442ae68856c65ac9751 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 3 Feb 2020 18:41:32 -0800 Subject: [PATCH 02/15] Add header for module eveL explaining what it is. Exclude modeveL-gen.h from Sphinx build --- conf.py | 1 + shared-bindings/eveL/__init__.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/conf.py b/conf.py index 3b29986c0646..79af70cbac90 100644 --- a/conf.py +++ b/conf.py @@ -156,6 +156,7 @@ "ports/zephyr", "py", "shared-bindings/util.*", + "shared-bindings/eveL/modeveL-gen.h", "shared-module", "supervisor", "tests", diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c index 3bbffa257f75..7a549b856cbb 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/eveL/__init__.c @@ -33,6 +33,18 @@ // #if MICROPY_PY_BUILTINS_EVEL +//| :mod:`eveL` --- low-level BridgeTek EVE bindings +//| ================================================ +//| +//| .. module:: eveL +//| :synopsis: low-level BridgeTek EVE bindings +//| :platform: SAMD21/SAMD51 +//| +//| The `eveL` module provides a class EVEL which +//| contains methods for constructing EVE command +//| buffers and appending basic graphics commands. +//| + typedef struct _mp_obj_EVEL_t { mp_obj_base_t base; mp_obj_t writer; From 8347f2b5c3a441e9c30ff70d4d779f9b236cf7df Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 3 Feb 2020 19:23:42 -0800 Subject: [PATCH 03/15] Correct default state to off for eveL module. Fix build break because of overflowing small ports --- py/circuitpy_mpconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index f56d994789f6..b72eec7c5bbf 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -175,7 +175,7 @@ endif CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) ifndef CIRCUITPY_EVEL -CIRCUITPY_EVEL = $(CIRCUITPY_ALWAYS_BUILD) +CIRCUITPY_EVEL = 0 endif CFLAGS += -DCIRCUITPY_EVEL=$(CIRCUITPY_EVEL) From 53f7e2be4fae30359b8208c87b7ae71fdf25f421 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 17:58:59 -0800 Subject: [PATCH 04/15] Use mp_instance_cast_to_native_base() throughout --- shared-bindings/eveL/__init__.c | 44 +++++++++++---------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c index 7a549b856cbb..06b4e0337e94 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/eveL/__init__.c @@ -31,8 +31,6 @@ #include "py/runtime.h" #include "py/binary.h" -// #if MICROPY_PY_BUILTINS_EVEL - //| :mod:`eveL` --- low-level BridgeTek EVE bindings //| ================================================ //| @@ -47,30 +45,28 @@ typedef struct _mp_obj_EVEL_t { mp_obj_base_t base; - mp_obj_t writer; mp_obj_t dest[3]; - size_t n; uint8_t buf[512]; } mp_obj_EVEL_t; +STATIC const mp_obj_type_t EVEL_type; + STATIC void _write(mp_obj_EVEL_t *EVEL, mp_obj_t b) { EVEL->dest[2] = b; mp_call_method_n_kw(1, 0, EVEL->dest); } STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { - mp_obj_EVEL_t *EVEL = self; + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); EVEL->n = 0; - mp_printf(&mp_plat_print, "register %p %d\n", EVEL, EVEL->n); mp_load_method(o, MP_QSTR_write, EVEL->dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); STATIC mp_obj_t _flush(mp_obj_t self) { - mp_obj_EVEL_t *EVEL = self; - // mp_printf(&mp_plat_print, "flush %p %d\n", EVEL, EVEL->n); + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); if (EVEL->n != 0) { _write(EVEL, mp_obj_new_bytearray_by_ref(EVEL->n, EVEL->buf)); EVEL->n = 0; @@ -79,19 +75,19 @@ STATIC mp_obj_t _flush(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); -STATIC void *append(mp_obj_EVEL_t *EVEL, size_t m) { - if ((EVEL->n + m) > sizeof(EVEL->buf)) - _flush((mp_obj_t)EVEL); - uint8_t *r = EVEL->buf + EVEL->n; - EVEL->n += m; - return (void*)r; +STATIC void *append(mp_obj_t self, size_t m) { + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); + if ((EVEL->n + m) > sizeof(EVEL->buf)) + _flush((mp_obj_t)EVEL); + uint8_t *r = EVEL->buf + EVEL->n; + EVEL->n += m; + return (void*)r; } STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { - mp_obj_EVEL_t *EVEL = self; + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); - // mp_printf(&mp_plat_print, "flush %p %d %p\n", EVEL, buffer_info.len, EVEL->writer); if (buffer_info.len <= sizeof(EVEL->buf)) { uint8_t *p = (uint8_t*)append(EVEL, buffer_info.len); // memcpy(p, buffer_info.buf, buffer_info.len); @@ -152,7 +148,6 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { break; } } - mp_printf(&mp_plat_print, "n=%d\n", n); uint32_t *p = (uint32_t*)append(self, sizeof(uint32_t) * (1 + n)); *p++ = 0xffffff00 | mp_obj_get_int_truncated(num); @@ -164,7 +159,6 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { case 'I': case 'i': *p++ = mp_obj_get_int_truncated(*a++); - mp_printf(&mp_plat_print, " %d %08x\n", p[-1]); i += 1; break; case 'H': @@ -201,17 +195,11 @@ STATIC void EVEL_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ STATIC mp_obj_t EVEL_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); mp_obj_EVEL_t *o = m_new_obj(mp_obj_EVEL_t); - mp_printf(&mp_plat_print, "EVEL init\n"); - o->base.type = type; - return o; + mp_printf(&mp_plat_print, "EVEL %p make_new\n", o); + o->base.type = &EVEL_type; + return MP_OBJ_FROM_PTR(o); } -// STATIC void EVEL_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { -// printf("HERE\n"); -// mp_type_type.attr(self_in, attr, dest); -// printf("THERE %p %p\n", dest[0], dest[1]); -// } - STATIC const mp_obj_type_t EVEL_type = { { &mp_type_type }, // Save on qstr's, reuse same as for module @@ -233,5 +221,3 @@ const mp_obj_module_t eveL_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_eveL_globals, }; - -// #endif // MICROPY_PY_BUILTINS_EVEL From a9b34f45dc821ad14c24aec7df6be74138fe4196 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 18:01:25 -0800 Subject: [PATCH 05/15] My name --- shared-bindings/eveL/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c index 06b4e0337e94..fa4439cbe2a9 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/eveL/__init__.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2014 Paul Sokolovsky + * Copyright (c) 2020 James Bowman * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From acef93a25391594111c1ded0614c440e04e23d26 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 18:17:58 -0800 Subject: [PATCH 06/15] Rename eveL to _eve, EVEL to _EVE --- .../boards/metro_m4_express/mpconfigboard.mk | 2 +- .../metro_nrf52840_express/mpconfigboard.mk | 2 +- py/circuitpy_defns.mk | 6 +- py/circuitpy_mpconfig.h | 10 +- py/circuitpy_mpconfig.mk | 6 +- shared-bindings/{eveL => _eve}/__init__.c | 92 +++++++++---------- .../modeveL-gen.h => _eve/mod_eve-gen.h} | 0 7 files changed, 59 insertions(+), 59 deletions(-) rename shared-bindings/{eveL => _eve}/__init__.c (71%) rename shared-bindings/{eveL/modeveL-gen.h => _eve/mod_eve-gen.h} (100%) diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk index d4593f83a594..c2603002cd70 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk @@ -11,4 +11,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ -CIRCUITPY_EVEL = 1 +CIRCUITPY__EVE = 1 diff --git a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk index ade77f0765df..b972bcbed7a1 100644 --- a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk +++ b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk @@ -9,4 +9,4 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "GD25Q16C" -CIRCUITPY_EVEL = 1 +CIRCUITPY__EVE = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 859d3837b106..e7d49ae24869 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -157,8 +157,8 @@ endif ifeq ($(CIRCUITPY_MATH),1) SRC_PATTERNS += math/% endif -ifeq ($(CIRCUITPY_EVEL),1) -SRC_PATTERNS += eveL/% +ifeq ($(CIRCUITPY__EVE),1) +SRC_PATTERNS += _eve/% endif ifeq ($(CIRCUITPY_MICROCONTROLLER),1) SRC_PATTERNS += microcontroller/% @@ -301,7 +301,7 @@ $(filter $(SRC_PATTERNS), \ fontio/Glyph.c \ microcontroller/RunMode.c \ math/__init__.c \ - eveL/__init__.c \ + _eve/__init__.c \ ) SRC_BINDINGS_ENUMS += \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 8b7ac46b0420..c1ac2cddb65d 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -384,11 +384,11 @@ extern const struct _mp_obj_module_t math_module; #define MATH_MODULE #endif -#if CIRCUITPY_EVEL -extern const struct _mp_obj_module_t eveL_module; -#define EVEL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_eveL), (mp_obj_t)&eveL_module }, +#if CIRCUITPY__EVE +extern const struct _mp_obj_module_t _eve_module; +#define _EVE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__eve), (mp_obj_t)&_eve_module }, #else -#define EVEL_MODULE +#define _EVE_MODULE #endif #if CIRCUITPY_MICROCONTROLLER @@ -624,7 +624,7 @@ extern const struct _mp_obj_module_t ustack_module; I2CSLAVE_MODULE \ JSON_MODULE \ MATH_MODULE \ - EVEL_MODULE \ + _EVE_MODULE \ MICROCONTROLLER_MODULE \ NEOPIXEL_WRITE_MODULE \ NETWORK_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index b72eec7c5bbf..93e5982d5c9e 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -174,10 +174,10 @@ CIRCUITPY_MATH = $(CIRCUITPY_ALWAYS_BUILD) endif CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) -ifndef CIRCUITPY_EVEL -CIRCUITPY_EVEL = 0 +ifndef CIRCUITPY__EVE +CIRCUITPY__EVE = 0 endif -CFLAGS += -DCIRCUITPY_EVEL=$(CIRCUITPY_EVEL) +CFLAGS += -DCIRCUITPY__EVE=$(CIRCUITPY__EVE) ifndef CIRCUITPY_MICROCONTROLLER CIRCUITPY_MICROCONTROLLER = $(CIRCUITPY_DEFAULT_BUILD) diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/_eve/__init__.c similarity index 71% rename from shared-bindings/eveL/__init__.c rename to shared-bindings/_eve/__init__.c index fa4439cbe2a9..5263fe1274e1 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -31,72 +31,72 @@ #include "py/runtime.h" #include "py/binary.h" -//| :mod:`eveL` --- low-level BridgeTek EVE bindings +//| :mod:`_eve` --- low-level BridgeTek EVE bindings //| ================================================ //| -//| .. module:: eveL +//| .. module:: _eve //| :synopsis: low-level BridgeTek EVE bindings //| :platform: SAMD21/SAMD51 //| -//| The `eveL` module provides a class EVEL which +//| The `_eve` module provides a class _EVE which //| contains methods for constructing EVE command //| buffers and appending basic graphics commands. //| -typedef struct _mp_obj_EVEL_t { +typedef struct _mp_obj__EVE_t { mp_obj_base_t base; mp_obj_t dest[3]; size_t n; uint8_t buf[512]; -} mp_obj_EVEL_t; +} mp_obj__EVE_t; -STATIC const mp_obj_type_t EVEL_type; +STATIC const mp_obj_type_t _EVE_type; -STATIC void _write(mp_obj_EVEL_t *EVEL, mp_obj_t b) { - EVEL->dest[2] = b; - mp_call_method_n_kw(1, 0, EVEL->dest); +STATIC void _write(mp_obj__EVE_t *_EVE, mp_obj_t b) { + _EVE->dest[2] = b; + mp_call_method_n_kw(1, 0, _EVE->dest); } STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); - EVEL->n = 0; - mp_load_method(o, MP_QSTR_write, EVEL->dest); + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + _EVE->n = 0; + mp_load_method(o, MP_QSTR_write, _EVE->dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); STATIC mp_obj_t _flush(mp_obj_t self) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); - if (EVEL->n != 0) { - _write(EVEL, mp_obj_new_bytearray_by_ref(EVEL->n, EVEL->buf)); - EVEL->n = 0; + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + if (_EVE->n != 0) { + _write(_EVE, mp_obj_new_bytearray_by_ref(_EVE->n, _EVE->buf)); + _EVE->n = 0; } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); STATIC void *append(mp_obj_t self, size_t m) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); - if ((EVEL->n + m) > sizeof(EVEL->buf)) - _flush((mp_obj_t)EVEL); - uint8_t *r = EVEL->buf + EVEL->n; - EVEL->n += m; + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + if ((_EVE->n + m) > sizeof(_EVE->buf)) + _flush((mp_obj_t)_EVE); + uint8_t *r = _EVE->buf + _EVE->n; + _EVE->n += m; return (void*)r; } STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); - if (buffer_info.len <= sizeof(EVEL->buf)) { - uint8_t *p = (uint8_t*)append(EVEL, buffer_info.len); + if (buffer_info.len <= sizeof(_EVE->buf)) { + uint8_t *p = (uint8_t*)append(_EVE, buffer_info.len); // memcpy(p, buffer_info.buf, buffer_info.len); uint8_t *s = buffer_info.buf; for (size_t i = 0; i < buffer_info.len; i++) *p++ = *s++; } else { _flush(self); - _write(EVEL, b); + _write(_EVE, b); } return mp_const_none; @@ -105,7 +105,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); #define C4(self, u) (*(uint32_t*)append((self), sizeof(uint32_t)) = (u)) -#include "modeveL-gen.h" +#include "mod_eve-gen.h" // Hand-written functions { @@ -175,7 +175,7 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cmd_obj, 4, 4, _cmd); -STATIC const mp_rom_map_elem_t EVEL_locals_dict_table[] = { +STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(®ister_obj) }, { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, @@ -184,40 +184,40 @@ STATIC const mp_rom_map_elem_t EVEL_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, ROM_DECLS }; -STATIC MP_DEFINE_CONST_DICT(EVEL_locals_dict, EVEL_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(_EVE_locals_dict, _EVE_locals_dict_table); -STATIC void EVEL_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void _EVE_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)self_in; (void)kind; - mp_printf(print, ""); + mp_printf(print, "<_EVE>"); } -STATIC mp_obj_t EVEL_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); - mp_obj_EVEL_t *o = m_new_obj(mp_obj_EVEL_t); - mp_printf(&mp_plat_print, "EVEL %p make_new\n", o); - o->base.type = &EVEL_type; + mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); + mp_printf(&mp_plat_print, "_EVE %p make_new\n", o); + o->base.type = &_EVE_type; return MP_OBJ_FROM_PTR(o); } -STATIC const mp_obj_type_t EVEL_type = { +STATIC const mp_obj_type_t _EVE_type = { { &mp_type_type }, // Save on qstr's, reuse same as for module - .name = MP_QSTR_EVEL, - .print = EVEL_print, - .make_new = EVEL_make_new, - // .attr = EVEL_attr, - .locals_dict = (void*)&EVEL_locals_dict, + .name = MP_QSTR__EVE, + .print = _EVE_print, + .make_new = _EVE_make_new, + // .attr = _EVE_attr, + .locals_dict = (void*)&_EVE_locals_dict, }; -STATIC const mp_rom_map_elem_t mp_module_eveL_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_eveL) }, - { MP_ROM_QSTR(MP_QSTR_EVEL), MP_OBJ_FROM_PTR(&EVEL_type) }, +STATIC const mp_rom_map_elem_t mp_module__eve_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__eve) }, + { MP_ROM_QSTR(MP_QSTR__EVE), MP_OBJ_FROM_PTR(&_EVE_type) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_eveL_globals, mp_module_eveL_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module__eve_globals, mp_module__eve_globals_table); -const mp_obj_module_t eveL_module = { +const mp_obj_module_t _eve_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_eveL_globals, + .globals = (mp_obj_dict_t*)&mp_module__eve_globals, }; diff --git a/shared-bindings/eveL/modeveL-gen.h b/shared-bindings/_eve/mod_eve-gen.h similarity index 100% rename from shared-bindings/eveL/modeveL-gen.h rename to shared-bindings/_eve/mod_eve-gen.h From 09a9e365dd7d45db112ace927d9c1d3f9d7ddf1a Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 19:56:29 -0800 Subject: [PATCH 07/15] Fix sphinx exclude for eveL -> _eve rename --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 79af70cbac90..4ea4ba4e8032 100644 --- a/conf.py +++ b/conf.py @@ -156,7 +156,7 @@ "ports/zephyr", "py", "shared-bindings/util.*", - "shared-bindings/eveL/modeveL-gen.h", + "shared-bindings/_eve/mod_eve-gen.h", "shared-module", "supervisor", "tests", From a20490c0b3f17355765f22cd6b102d27824d33ec Mon Sep 17 00:00:00 2001 From: James Bowman Date: Thu, 6 Feb 2020 08:49:07 -0800 Subject: [PATCH 08/15] Add method VertexFormat() and variable fixed-point scaling in Vertex2f() --- shared-bindings/_eve/__init__.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 5263fe1274e1..8d36118da276 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -45,9 +45,10 @@ typedef struct _mp_obj__EVE_t { mp_obj_base_t base; - mp_obj_t dest[3]; - size_t n; - uint8_t buf[512]; + mp_obj_t dest[3]; // Own 'write' method, plus argument + int vscale; // fixed-point scaling used for Vertex2f + size_t n; // Current size of command buffer + uint8_t buf[512]; // Command buffer } mp_obj__EVE_t; STATIC const mp_obj_type_t _EVE_type; @@ -59,7 +60,6 @@ STATIC void _write(mp_obj__EVE_t *_EVE, mp_obj_t b) { STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - _EVE->n = 0; mp_load_method(o, MP_QSTR_write, _EVE->dest); return mp_const_none; } @@ -115,14 +115,24 @@ STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); -STATIC mp_obj_t _vertex2f(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - int16_t x = (int16_t)(16 * mp_obj_get_float(a0)); - int16_t y = (int16_t)(16 * mp_obj_get_float(a1)); +STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + int16_t x = (int16_t)(_EVE->vscale * mp_obj_get_float(a0)); + int16_t y = (int16_t)(_EVE->vscale * mp_obj_get_float(a1)); C4(self, (0x40000000 | ((x & 32767) << 15) | (y & 32767))); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); +STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + uint32_t frac = mp_obj_get_int_truncated(a0); + C4(self, ((0x27 << 24) | (frac & 3))); + _EVE->vscale = 1 << frac; + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); + STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; mp_obj_t num = args[1]; @@ -180,6 +190,7 @@ STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2f), MP_ROM_PTR(&vertex2f_obj) }, + { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd), MP_ROM_PTR(&cmd_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, ROM_DECLS @@ -197,6 +208,8 @@ STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); mp_printf(&mp_plat_print, "_EVE %p make_new\n", o); o->base.type = &_EVE_type; + o->n = 0; + o->vscale = 16; return MP_OBJ_FROM_PTR(o); } From 5c6d94d3e5ac2c4bb8514ac920d59a465300465b Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 7 Feb 2020 10:30:49 -0800 Subject: [PATCH 09/15] Split into shared-module and shared-bindings --- py/circuitpy_defns.mk | 3 +- shared-bindings/_eve/__init__.c | 80 ++----- shared-bindings/_eve/mod_eve-gen.h | 372 +++++++++++++---------------- shared-module/_eve/__init__.c | 270 +++++++++++++++++++++ shared-module/_eve/__init__.h | 91 +++++++ 5 files changed, 557 insertions(+), 259 deletions(-) create mode 100644 shared-module/_eve/__init__.c create mode 100644 shared-module/_eve/__init__.h diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index e7d49ae24869..68fa25d8d8bc 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -363,7 +363,8 @@ SRC_SHARED_MODULE_ALL = \ uheap/__init__.c \ ustack/__init__.c \ _pew/__init__.c \ - _pew/PewPew.c + _pew/PewPew.c \ + _eve/__init__.c # All possible sources are listed here, and are filtered by SRC_PATTERNS. SRC_SHARED_MODULE = $(filter $(SRC_PATTERNS), $(SRC_SHARED_MODULE_ALL)) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 8d36118da276..6f2a39db50c9 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -31,6 +31,8 @@ #include "py/runtime.h" #include "py/binary.h" +#include "shared-module/_eve/__init__.h" + //| :mod:`_eve` --- low-level BridgeTek EVE bindings //| ================================================ //| @@ -45,94 +47,57 @@ typedef struct _mp_obj__EVE_t { mp_obj_base_t base; - mp_obj_t dest[3]; // Own 'write' method, plus argument - int vscale; // fixed-point scaling used for Vertex2f - size_t n; // Current size of command buffer - uint8_t buf[512]; // Command buffer + common_hal__eve_t _eve; } mp_obj__EVE_t; STATIC const mp_obj_type_t _EVE_type; -STATIC void _write(mp_obj__EVE_t *_EVE, mp_obj_t b) { - _EVE->dest[2] = b; - mp_call_method_n_kw(1, 0, _EVE->dest); -} +#define EVEHAL(s) \ + (&((mp_obj__EVE_t*)mp_instance_cast_to_native_base((s), &_EVE_type))->_eve) STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - mp_load_method(o, MP_QSTR_write, _EVE->dest); + common_hal__eve_t *eve = EVEHAL(self); + mp_load_method(o, MP_QSTR_write, eve->dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); STATIC mp_obj_t _flush(mp_obj_t self) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - if (_EVE->n != 0) { - _write(_EVE, mp_obj_new_bytearray_by_ref(_EVE->n, _EVE->buf)); - _EVE->n = 0; - } + common_hal__eve_flush(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); -STATIC void *append(mp_obj_t self, size_t m) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - if ((_EVE->n + m) > sizeof(_EVE->buf)) - _flush((mp_obj_t)_EVE); - uint8_t *r = _EVE->buf + _EVE->n; - _EVE->n += m; - return (void*)r; -} - STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); - if (buffer_info.len <= sizeof(_EVE->buf)) { - uint8_t *p = (uint8_t*)append(_EVE, buffer_info.len); - // memcpy(p, buffer_info.buf, buffer_info.len); - uint8_t *s = buffer_info.buf; - for (size_t i = 0; i < buffer_info.len; i++) - *p++ = *s++; - } else { - _flush(self); - _write(_EVE, b); - } - + common_hal__eve_add(EVEHAL(self), buffer_info.len, buffer_info.buf); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); -#define C4(self, u) (*(uint32_t*)append((self), sizeof(uint32_t)) = (u)) - #include "mod_eve-gen.h" // Hand-written functions { +#define ADD_X(self, x) \ + common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); + STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { - C4(self, (0xffffff00 | mp_obj_get_int_truncated(n))); + uint32_t code = 0xffffff00 | mp_obj_get_int_truncated(n); + ADD_X(self, code); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - int16_t x = (int16_t)(_EVE->vscale * mp_obj_get_float(a0)); - int16_t y = (int16_t)(_EVE->vscale * mp_obj_get_float(a1)); - C4(self, (0x40000000 | ((x & 32767) << 15) | (y & 32767))); + mp_float_t x = mp_obj_get_float(a0); + mp_float_t y = mp_obj_get_float(a1); + common_hal__eve_Vertex2f(EVEHAL(self), x, y); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); -STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - uint32_t frac = mp_obj_get_int_truncated(a0); - C4(self, ((0x27 << 24) | (frac & 3))); - _EVE->vscale = 1 << frac; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); - STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; mp_obj_t num = args[1]; @@ -159,7 +124,8 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { } } - uint32_t *p = (uint32_t*)append(self, sizeof(uint32_t) * (1 + n)); + uint32_t buf[16]; + uint32_t *p = buf; *p++ = 0xffffff00 | mp_obj_get_int_truncated(num); mp_obj_t *a = items; uint32_t lo; @@ -181,6 +147,8 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { break; } } + + common_hal__eve_add(EVEHAL(self), sizeof(uint32_t) * (1 + n), buf); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cmd_obj, 4, 4, _cmd); @@ -190,7 +158,6 @@ STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2f), MP_ROM_PTR(&vertex2f_obj) }, - { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd), MP_ROM_PTR(&cmd_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, ROM_DECLS @@ -206,10 +173,9 @@ STATIC void _EVE_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); - mp_printf(&mp_plat_print, "_EVE %p make_new\n", o); o->base.type = &_EVE_type; - o->n = 0; - o->vscale = 16; + o->_eve.n = 0; + o->_eve.vscale = 16; return MP_OBJ_FROM_PTR(o); } diff --git a/shared-bindings/_eve/mod_eve-gen.h b/shared-bindings/_eve/mod_eve-gen.h index 1c8d5ae12a91..c5dafb16f020 100644 --- a/shared-bindings/_eve/mod_eve-gen.h +++ b/shared-bindings/_eve/mod_eve-gen.h @@ -1,42 +1,37 @@ -STATIC mp_obj_t _alphafunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t func = mp_obj_get_int_truncated(a0); - uint32_t ref = mp_obj_get_int_truncated(a1); - C4(self, ((9 << 24) | ((func & 7) << 8) | ((ref & 255))) -); +STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t func = mp_obj_get_int_truncated(a0); + uint32_t ref = mp_obj_get_int_truncated(a1); + common_hal__eve_AlphaFunc(EVEHAL(self), func, ref); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); -STATIC mp_obj_t _begin(mp_obj_t self , mp_obj_t a0) { - uint32_t prim = mp_obj_get_int_truncated(a0); - C4(self, ((31 << 24) | ((prim & 15))) -); +STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { + uint32_t prim = mp_obj_get_int_truncated(a0); + common_hal__eve_Begin(EVEHAL(self), prim); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); -STATIC mp_obj_t _bitmapextformat(mp_obj_t self , mp_obj_t a0) { - uint32_t fmt = mp_obj_get_int_truncated(a0); - C4(self, ((46 << 24) | (fmt & 65535)) -); +STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { + uint32_t fmt = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapExtFormat(EVEHAL(self), fmt); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); -STATIC mp_obj_t _bitmaphandle(mp_obj_t self , mp_obj_t a0) { +STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { uint32_t handle = mp_obj_get_int_truncated(a0); - C4(self, ((5 << 24) | ((handle & 31))) -); + common_hal__eve_BitmapHandle(EVEHAL(self), handle); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); -STATIC mp_obj_t _bitmaplayouth(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { +STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t linestride = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); - C4(self, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3))) -); + common_hal__eve_BitmapLayoutH(EVEHAL(self), linestride, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); @@ -45,368 +40,343 @@ STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { uint32_t format = mp_obj_get_int_truncated(args[1]); uint32_t linestride = mp_obj_get_int_truncated(args[2]); uint32_t height = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511))) -); + common_hal__eve_BitmapLayout(EVEHAL(args[0]), format, linestride, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); -STATIC mp_obj_t _bitmapsizeh(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); +STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); - C4(self, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3))) -); + common_hal__eve_BitmapSizeH(EVEHAL(self), width, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { uint32_t filter = mp_obj_get_int_truncated(args[1]); - uint32_t wrapx = mp_obj_get_int_truncated(args[2]); - uint32_t wrapy = mp_obj_get_int_truncated(args[3]); - uint32_t width = mp_obj_get_int_truncated(args[4]); + uint32_t wrapx = mp_obj_get_int_truncated(args[2]); + uint32_t wrapy = mp_obj_get_int_truncated(args[3]); + uint32_t width = mp_obj_get_int_truncated(args[4]); uint32_t height = mp_obj_get_int_truncated(args[5]); - C4(args[0], ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511))) -); + common_hal__eve_BitmapSize(EVEHAL(args[0]), filter, wrapx, wrapy, width, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); -STATIC mp_obj_t _bitmapsource(mp_obj_t self , mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - C4(self, ((1 << 24) | ((addr & 0xffffff))) -); +STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapSource(EVEHAL(self), addr); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - C4(args[0], ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7))) -); + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_BitmapSwizzle(EVEHAL(args[0]), r, g, b, a); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); -STATIC mp_obj_t _bitmaptransforma(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t a = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((21 << 24) | ((p & 1) << 17) | ((a & 131071))) -); +STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t a = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); -STATIC mp_obj_t _bitmaptransformb(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t b = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((22 << 24) | ((p & 1) << 17) | ((b & 131071))) -); +STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t b = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); -STATIC mp_obj_t _bitmaptransformc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t c = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215))) -); +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t c = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); -STATIC mp_obj_t _bitmaptransformd(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t d = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((24 << 24) | ((p & 1) << 17) | ((d & 131071))) -); +STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t d = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); -STATIC mp_obj_t _bitmaptransforme(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t e = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((25 << 24) | ((p & 1) << 17) | ((e & 131071))) -); +STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t e = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); -STATIC mp_obj_t _bitmaptransformf(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t f = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215))) -); +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t f = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); -STATIC mp_obj_t _blendfunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t src = mp_obj_get_int_truncated(a0); - uint32_t dst = mp_obj_get_int_truncated(a1); - C4(self, ((11 << 24) | ((src & 7) << 3) | ((dst & 7))) -); +STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t src = mp_obj_get_int_truncated(a0); + uint32_t dst = mp_obj_get_int_truncated(a1); + common_hal__eve_BlendFunc(EVEHAL(self), src, dst); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); -STATIC mp_obj_t _call(mp_obj_t self , mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - C4(self, ((29 << 24) | ((dest & 65535))) -); +STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Call(EVEHAL(self), dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); -STATIC mp_obj_t _cell(mp_obj_t self , mp_obj_t a0) { - uint32_t cell = mp_obj_get_int_truncated(a0); - C4(self, ((6 << 24) | ((cell & 127))) -); +STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { + uint32_t cell = mp_obj_get_int_truncated(a0); + common_hal__eve_Cell(EVEHAL(self), cell); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); -STATIC mp_obj_t _clearcolora(mp_obj_t self , mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - C4(self, ((15 << 24) | ((alpha & 255))) -); +STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearColorA(EVEHAL(self), alpha); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) -); + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ClearColorRGB(EVEHAL(args[0]), red, green, blue); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { - uint32_t c = mp_obj_get_int_truncated(args[1]); - uint32_t s = mp_obj_get_int_truncated(args[2]); - uint32_t t = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1))) -); + uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; + uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; + uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; + common_hal__eve_Clear(EVEHAL(args[0]), c, s, t); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 4, 4, _clear); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); -STATIC mp_obj_t _clearstencil(mp_obj_t self , mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - C4(self, ((17 << 24) | ((s & 255))) -); +STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearStencil(EVEHAL(self), s); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); -STATIC mp_obj_t _cleartag(mp_obj_t self , mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - C4(self, ((18 << 24) | ((s & 255))) -); +STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearTag(EVEHAL(self), s); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); -STATIC mp_obj_t _colora(mp_obj_t self , mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - C4(self, ((16 << 24) | ((alpha & 255))) -); +STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ColorA(EVEHAL(self), alpha); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - C4(args[0], ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1))) -); + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_ColorMask(EVEHAL(args[0]), r, g, b, a); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) -); + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ColorRGB(EVEHAL(args[0]), red, green, blue); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); -STATIC mp_obj_t _display(mp_obj_t self ) { +STATIC mp_obj_t _display(mp_obj_t self) { - C4(self, ((0 << 24)) -); + common_hal__eve_Display(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); -STATIC mp_obj_t _end(mp_obj_t self ) { +STATIC mp_obj_t _end(mp_obj_t self) { - C4(self, ((33 << 24)) -); + common_hal__eve_End(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); -STATIC mp_obj_t _jump(mp_obj_t self , mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - C4(self, ((30 << 24) | ((dest & 65535))) -); +STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Jump(EVEHAL(self), dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); -STATIC mp_obj_t _linewidth(mp_obj_t self , mp_obj_t a0) { - uint32_t width = mp_obj_get_int_truncated(a0); - C4(self, ((14 << 24) | ((width & 4095))) -); +STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { + uint32_t width = mp_obj_get_int_truncated(a0); + common_hal__eve_LineWidth(EVEHAL(self), width); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); -STATIC mp_obj_t _macro(mp_obj_t self , mp_obj_t a0) { - uint32_t m = mp_obj_get_int_truncated(a0); - C4(self, ((37 << 24) | ((m & 1))) -); +STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { + uint32_t m = mp_obj_get_int_truncated(a0); + common_hal__eve_Macro(EVEHAL(self), m); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); -STATIC mp_obj_t _nop(mp_obj_t self ) { +STATIC mp_obj_t _nop(mp_obj_t self) { - C4(self, ((45 << 24)) -); + common_hal__eve_Nop(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); -STATIC mp_obj_t _palettesource(mp_obj_t self , mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - C4(self, ((42 << 24) | (((addr) & 4194303))) -); +STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_PaletteSource(EVEHAL(self), addr); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); -STATIC mp_obj_t _pointsize(mp_obj_t self , mp_obj_t a0) { - uint32_t size = mp_obj_get_int_truncated(a0); - C4(self, ((13 << 24) | ((size & 8191))) -); +STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { + uint32_t size = mp_obj_get_int_truncated(a0); + common_hal__eve_PointSize(EVEHAL(self), size); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); -STATIC mp_obj_t _restorecontext(mp_obj_t self ) { +STATIC mp_obj_t _restorecontext(mp_obj_t self) { - C4(self, ((35 << 24)) -); + common_hal__eve_RestoreContext(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); -STATIC mp_obj_t _return(mp_obj_t self ) { +STATIC mp_obj_t _return(mp_obj_t self) { - C4(self, ((36 << 24)) -); + common_hal__eve_Return(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); -STATIC mp_obj_t _savecontext(mp_obj_t self ) { +STATIC mp_obj_t _savecontext(mp_obj_t self) { - C4(self, ((34 << 24)) -); + common_hal__eve_SaveContext(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); -STATIC mp_obj_t _scissorsize(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); +STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); - C4(self, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095))) -); + common_hal__eve_ScissorSize(EVEHAL(self), width, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); -STATIC mp_obj_t _scissorxy(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t x = mp_obj_get_int_truncated(a0); - uint32_t y = mp_obj_get_int_truncated(a1); - C4(self, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047))) -); +STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t x = mp_obj_get_int_truncated(a0); + uint32_t y = mp_obj_get_int_truncated(a1); + common_hal__eve_ScissorXY(EVEHAL(self), x, y); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { - uint32_t func = mp_obj_get_int_truncated(args[1]); - uint32_t ref = mp_obj_get_int_truncated(args[2]); - uint32_t mask = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255))) -); + uint32_t func = mp_obj_get_int_truncated(args[1]); + uint32_t ref = mp_obj_get_int_truncated(args[2]); + uint32_t mask = mp_obj_get_int_truncated(args[3]); + common_hal__eve_StencilFunc(EVEHAL(args[0]), func, ref, mask); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); -STATIC mp_obj_t _stencilmask(mp_obj_t self , mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - C4(self, ((19 << 24) | ((mask & 255))) -); +STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_StencilMask(EVEHAL(self), mask); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); -STATIC mp_obj_t _stencilop(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t sfail = mp_obj_get_int_truncated(a0); - uint32_t spass = mp_obj_get_int_truncated(a1); - C4(self, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7))) -); +STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t sfail = mp_obj_get_int_truncated(a0); + uint32_t spass = mp_obj_get_int_truncated(a1); + common_hal__eve_StencilOp(EVEHAL(self), sfail, spass); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); -STATIC mp_obj_t _tagmask(mp_obj_t self , mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - C4(self, ((20 << 24) | ((mask & 1))) -); +STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_TagMask(EVEHAL(self), mask); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); -STATIC mp_obj_t _tag(mp_obj_t self , mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - C4(self, ((3 << 24) | ((s & 255))) -); +STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_Tag(EVEHAL(self), s); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); -STATIC mp_obj_t _vertextranslatex(mp_obj_t self , mp_obj_t a0) { - uint32_t x = mp_obj_get_int_truncated(a0); - C4(self, ((43 << 24) | (((x) & 131071))) -); +STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { + uint32_t x = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateX(EVEHAL(self), x); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); -STATIC mp_obj_t _vertextranslatey(mp_obj_t self , mp_obj_t a0) { - uint32_t y = mp_obj_get_int_truncated(a0); - C4(self, ((44 << 24) | (((y) & 131071))) -); +STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { + uint32_t y = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateY(EVEHAL(self), y); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); -#define N_METHODS 47 -#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; } while (0) -#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) } + +STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { + uint32_t frac = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexFormat(EVEHAL(self), frac); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); + +STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { + uint32_t x = mp_obj_get_int_truncated(args[1]); + uint32_t y = mp_obj_get_int_truncated(args[2]); + uint32_t handle = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 0; + uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; + common_hal__eve_Vertex2ii(EVEHAL(args[0]), x, y, handle, cell); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); +#define N_METHODS 49 +#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) +#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c new file mode 100644 index 000000000000..ca6fd4031b43 --- /dev/null +++ b/shared-module/_eve/__init__.c @@ -0,0 +1,270 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 James Bowman for Excamera Labs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include "py/runtime.h" +#include "shared-module/_eve/__init__.h" + +STATIC void write(common_hal__eve_t *eve, size_t len, void *buf) { + eve->dest[2] = mp_obj_new_bytearray_by_ref(len, buf); + mp_call_method_n_kw(1, 0, eve->dest); +} + +void common_hal__eve_flush(common_hal__eve_t *eve) { + if (eve->n != 0) { + write(eve, eve->n, eve->buf); + eve->n = 0; + } +} + +static void *append(common_hal__eve_t *eve, size_t m) { + if ((eve->n + m) > sizeof(eve->buf)) + common_hal__eve_flush(eve); + uint8_t *r = eve->buf + eve->n; + eve->n += m; + return (void*)r; +} + +void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf) { + if (len <= sizeof(eve->buf)) { + uint8_t *p = (uint8_t*)append(eve, len); + // memcpy(p, buffer_info.buf, buffer_info.len); + uint8_t *s = buf; for (size_t i = 0; i < len; i++) *p++ = *s++; + } else { + common_hal__eve_flush(eve); + write(eve, len, buf); + } +} + +#define C4(eve, u) (*(uint32_t*)append((eve), sizeof(uint32_t)) = (u)) + +void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y) { + int16_t ix = (int)(eve->vscale * x); + int16_t iy = (int)(eve->vscale * y); + C4(eve, (1 << 30) | ((ix & 32767) << 15) | (iy & 32767)); +} + +void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac) +{ + C4(eve, ((27 << 24) | ((frac & 7)))); + eve->vscale = 1 << eve->vscale; +} + + + +void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref) { + C4(eve, ((9 << 24) | ((func & 7) << 8) | ((ref & 255)))); +} + +void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim) { + C4(eve, ((31 << 24) | ((prim & 15)))); +} + +void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt) { + C4(eve, ((46 << 24) | (fmt & 65535))); +} + +void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle) { + C4(eve, ((5 << 24) | ((handle & 31)))); +} + +void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height) { + C4(eve, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3)))); +} + +void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height) { + C4(eve, ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511)))); +} + +void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height) { + C4(eve, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3)))); +} + +void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height) { + C4(eve, ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511)))); +} + +void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr) { + C4(eve, ((1 << 24) | ((addr & 0xffffff)))); +} + +void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { + C4(eve, ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7)))); +} + +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p) { + C4(eve, ((21 << 24) | ((p & 1) << 17) | ((a & 131071)))); +} + +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p) { + C4(eve, ((22 << 24) | ((p & 1) << 17) | ((b & 131071)))); +} + +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p) { + C4(eve, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215)))); +} + +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p) { + C4(eve, ((24 << 24) | ((p & 1) << 17) | ((d & 131071)))); +} + +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p) { + C4(eve, ((25 << 24) | ((p & 1) << 17) | ((e & 131071)))); +} + +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p) { + C4(eve, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215)))); +} + +void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst) { + C4(eve, ((11 << 24) | ((src & 7) << 3) | ((dst & 7)))); +} + +void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest) { + C4(eve, ((29 << 24) | ((dest & 65535)))); +} + +void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell) { + C4(eve, ((6 << 24) | ((cell & 127)))); +} + +void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha) { + C4(eve, ((15 << 24) | ((alpha & 255)))); +} + +void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { + C4(eve, ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); +} + +void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t) { + C4(eve, ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1)))); +} + +void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s) { + C4(eve, ((17 << 24) | ((s & 255)))); +} + +void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s) { + C4(eve, ((18 << 24) | ((s & 255)))); +} + +void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha) { + C4(eve, ((16 << 24) | ((alpha & 255)))); +} + +void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { + C4(eve, ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1)))); +} + +void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { + C4(eve, ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); +} + +void common_hal__eve_Display(common_hal__eve_t *eve) { + C4(eve, ((0 << 24))); +} + +void common_hal__eve_End(common_hal__eve_t *eve) { + C4(eve, ((33 << 24))); +} + +void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest) { + C4(eve, ((30 << 24) | ((dest & 65535)))); +} + +void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width) { + C4(eve, ((14 << 24) | ((width & 4095)))); +} + +void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m) { + C4(eve, ((37 << 24) | ((m & 1)))); +} + +void common_hal__eve_Nop(common_hal__eve_t *eve) { + C4(eve, ((45 << 24))); +} + +void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr) { + C4(eve, ((42 << 24) | (((addr) & 4194303)))); +} + +void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size) { + C4(eve, ((13 << 24) | ((size & 8191)))); +} + +void common_hal__eve_RestoreContext(common_hal__eve_t *eve) { + C4(eve, ((35 << 24))); +} + +void common_hal__eve_Return(common_hal__eve_t *eve) { + C4(eve, ((36 << 24))); +} + +void common_hal__eve_SaveContext(common_hal__eve_t *eve) { + C4(eve, ((34 << 24))); +} + +void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height) { + C4(eve, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095)))); +} + +void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y) { + C4(eve, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047)))); +} + +void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask) { + C4(eve, ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255)))); +} + +void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask) { + C4(eve, ((19 << 24) | ((mask & 255)))); +} + +void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass) { + C4(eve, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7)))); +} + +void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask) { + C4(eve, ((20 << 24) | ((mask & 1)))); +} + +void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s) { + C4(eve, ((3 << 24) | ((s & 255)))); +} + +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x) { + C4(eve, ((43 << 24) | (((x) & 131071)))); +} + +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y) { + C4(eve, ((44 << 24) | (((y) & 131071)))); +} + +void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell) { + C4(eve, ((2 << 30) | (((x) & 511) << 21) | (((y) & 511) << 12) | (((handle) & 31) << 7) | (((cell) & 127) << 0))); +} + diff --git a/shared-module/_eve/__init__.h b/shared-module/_eve/__init__.h new file mode 100644 index 000000000000..f2fd7a943887 --- /dev/null +++ b/shared-module/_eve/__init__.h @@ -0,0 +1,91 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 James Bowman for Excamera Labs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H +#define MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H + +typedef struct _common_hal__eve_t { + mp_obj_t dest[3]; // Own 'write' method, plus argument + int vscale; // fixed-point scaling used for Vertex2f + size_t n; // Current size of command buffer + uint8_t buf[512]; // Command buffer +} common_hal__eve_t; + +void common_hal__eve_flush(common_hal__eve_t *eve); +void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf); +void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y); + +void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref); +void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim); +void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt); +void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle); +void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); +void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); +void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); +void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t); +void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Display(common_hal__eve_t *eve); +void common_hal__eve_End(common_hal__eve_t *eve); +void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width); +void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m); +void common_hal__eve_Nop(common_hal__eve_t *eve); +void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size); +void common_hal__eve_RestoreContext(common_hal__eve_t *eve); +void common_hal__eve_Return(common_hal__eve_t *eve); +void common_hal__eve_SaveContext(common_hal__eve_t *eve); +void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y); +void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask); +void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass); +void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x); +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y); +void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac); +void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell); + +#endif // MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H From c631b4d60eddea88e5f066356859252c2cc486b8 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 7 Feb 2020 16:44:48 -0800 Subject: [PATCH 10/15] Add doc strings, inline mod_eve-gen.h and remove it --- shared-bindings/_eve/__init__.c | 874 ++++++++++++++++++++++++++++- shared-bindings/_eve/mod_eve-gen.h | 382 ------------- 2 files changed, 866 insertions(+), 390 deletions(-) delete mode 100644 shared-bindings/_eve/mod_eve-gen.h diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 6f2a39db50c9..b398c0a5dd29 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -62,12 +62,24 @@ STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); +//| .. method:: flush() +//| +//| Send any queued drawing commands directly to the hardware. +//| +//| :param int width: The width of the grid in tiles, or 1 for sprites. +//| STATIC mp_obj_t _flush(mp_obj_t self) { common_hal__eve_flush(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); +//| .. method:: cc(b) +//| +//| Append bytes to the command FIFO. +//| +//| :param bytes b: The bytes to add +//| STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); @@ -76,20 +88,832 @@ STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); -#include "mod_eve-gen.h" +//{ -// Hand-written functions { +//| .. method:: AlphaFunc(func, ref) +//| +//| Set the alpha test function +//| +//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7) +//| :param int ref: specifies the reference value for the alpha test. Range 0-255. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| -#define ADD_X(self, x) \ - common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); +STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t func = mp_obj_get_int_truncated(a0); + uint32_t ref = mp_obj_get_int_truncated(a1); + common_hal__eve_AlphaFunc(EVEHAL(self), func, ref); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); -STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { - uint32_t code = 0xffffff00 | mp_obj_get_int_truncated(n); - ADD_X(self, code); +//| .. method:: Begin(prim) +//| +//| Begin drawing a graphics primitive +//| +//| :param int prim: graphics primitive. +//| +//| Valid primitives are ``BITMAPS``, ``POINTS``, ``LINES``, ``LINE_STRIP``, ``EDGE_STRIP_R``, ``EDGE_STRIP_L``, ``EDGE_STRIP_A``, ``EDGE_STRIP_B`` and ``RECTS``. +//| + +STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { + uint32_t prim = mp_obj_get_int_truncated(a0); + common_hal__eve_Begin(EVEHAL(self), prim); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); + +//| .. method:: BitmapExtFormat(format) +//| +//| Set the bitmap format +//| +//| :param int format: bitmap pixel format. +//| + +STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { + uint32_t fmt = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapExtFormat(EVEHAL(self), fmt); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); + +//| .. method:: BitmapHandle(handle) +//| +//| Set the bitmap handle +//| +//| :param int handle: bitmap handle. Range 0-31. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { + uint32_t handle = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapHandle(EVEHAL(self), handle); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); + +//| .. method:: BitmapLayoutH(linestride, height) +//| +//| Set the source bitmap memory format and layout for the current handle. high bits for large bitmaps +//| +//| :param int linestride: high part of bitmap line stride, in bytes. Range 0-7 +//| :param int height: high part of bitmap height, in lines. Range 0-3 +//| + +STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t linestride = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapLayoutH(EVEHAL(self), linestride, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); + +//| .. method:: BitmapLayout(format, linestride, height) +//| +//| Set the source bitmap memory format and layout for the current handle +//| +//| :param int format: bitmap pixel format, or GLFORMAT to use BITMAP_EXT_FORMAT instead. Range 0-31 +//| :param int linestride: bitmap line stride, in bytes. Range 0-1023 +//| :param int height: bitmap height, in lines. Range 0-511 +//| + +STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { + uint32_t format = mp_obj_get_int_truncated(args[1]); + uint32_t linestride = mp_obj_get_int_truncated(args[2]); + uint32_t height = mp_obj_get_int_truncated(args[3]); + common_hal__eve_BitmapLayout(EVEHAL(args[0]), format, linestride, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); + +//| .. method:: BitmapSizeH(width, height) +//| +//| Set the screen drawing of bitmaps for the current handle. high bits for large bitmaps +//| +//| :param int width: high part of drawn bitmap width, in pixels. Range 0-3 +//| :param int height: high part of drawn bitmap height, in pixels. Range 0-3 +//| + +STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapSizeH(EVEHAL(self), width, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); + +//| .. method:: BitmapSize(filter, wrapx, wrapy, width, height) +//| +//| Set the screen drawing of bitmaps for the current handle +//| +//| :param int filter: bitmap filtering mode, one of ``NEAREST`` or ``BILINEAR``. Range 0-1 +//| :param int wrapx: bitmap :math:`x` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1 +//| :param int wrapy: bitmap :math:`y` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1 +//| :param int width: drawn bitmap width, in pixels. Range 0-511 +//| :param int height: drawn bitmap height, in pixels. Range 0-511 +//| + +STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { + uint32_t filter = mp_obj_get_int_truncated(args[1]); + uint32_t wrapx = mp_obj_get_int_truncated(args[2]); + uint32_t wrapy = mp_obj_get_int_truncated(args[3]); + uint32_t width = mp_obj_get_int_truncated(args[4]); + uint32_t height = mp_obj_get_int_truncated(args[5]); + common_hal__eve_BitmapSize(EVEHAL(args[0]), filter, wrapx, wrapy, width, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); + +//| .. method:: BitmapSource(addr) +//| +//| Set the source address for bitmap graphics +//| +//| :param int addr: Bitmap start address, pixel-aligned. May be in SRAM or flash. Range 0-16777215 +//| + +STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapSource(EVEHAL(self), addr); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); + +//| .. method:: BitmapSwizzle(r, g, b, a) +//| +//| Set the source for the r,g,b and a channels of a bitmap +//| +//| :param int r: red component source channel. Range 0-7 +//| :param int g: green component source channel. Range 0-7 +//| :param int b: blue component source channel. Range 0-7 +//| :param int a: alpha component source channel. Range 0-7 +//| + +STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_BitmapSwizzle(EVEHAL(args[0]), r, g, b, a); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); + +//| .. method:: BitmapTransformA(p, v) +//| +//| Set the :math:`a` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`a` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t a = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); + +//| .. method:: BitmapTransformB(p, v) +//| +//| Set the :math:`b` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`b` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t b = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); + +//| .. method:: BitmapTransformC(c) +//| +//| Set the :math:`c` component of the bitmap transform matrix +//| +//| :param int c: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t c = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); + +//| .. method:: BitmapTransformD(p, v) +//| +//| Set the :math:`d` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`d` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t d = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); + +//| .. method:: BitmapTransformE(p, v) +//| +//| Set the :math:`e` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`e` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t e = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); +//| .. method:: BitmapTransformF(f) +//| +//| Set the :math:`f` component of the bitmap transform matrix +//| +//| :param int f: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t f = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); + +//| .. method:: BlendFunc(src, dst) +//| +//| Set pixel arithmetic +//| +//| :param int src: specifies how the source blending factor is computed. One of ``ZERO``, ``ONE``, ``SRC_ALPHA``, ``DST_ALPHA``, ``ONE_MINUS_SRC_ALPHA`` or ``ONE_MINUS_DST_ALPHA``. Range 0-7. The initial value is SRC_ALPHA(2) +//| :param int dst: specifies how the destination blending factor is computed, one of the same constants as **src**. Range 0-7. The initial value is ONE_MINUS_SRC_ALPHA(4) +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t src = mp_obj_get_int_truncated(a0); + uint32_t dst = mp_obj_get_int_truncated(a1); + common_hal__eve_BlendFunc(EVEHAL(self), src, dst); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); + +//| .. method:: Call(dest) +//| +//| Execute a sequence of commands at another location in the display list +//| +//| :param int dest: display list address. Range 0-65535 +//| + +STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Call(EVEHAL(self), dest); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); + +//| .. method:: Cell(cell) +//| +//| Set the bitmap cell number for the vertex2f command +//| +//| :param int cell: bitmap cell number. Range 0-127. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { + uint32_t cell = mp_obj_get_int_truncated(a0); + common_hal__eve_Cell(EVEHAL(self), cell); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); + +//| .. method:: ClearColorA(alpha) +//| +//| Set clear value for the alpha channel +//| +//| :param int alpha: alpha value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearColorA(EVEHAL(self), alpha); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); + +//| .. method:: ClearColorRGB(red, green, blue) +//| +//| Set clear values for red, green and blue channels +//| +//| :param int red: red value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| :param int green: green value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| :param int blue: blue value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ClearColorRGB(EVEHAL(args[0]), red, green, blue); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); + +//| .. method:: Clear(c, s, t) +//| +//| Clear buffers to preset values +//| +//| :param int c: clear color buffer. Range 0-1 +//| :param int s: clear stencil buffer. Range 0-1 +//| :param int t: clear tag buffer. Range 0-1 +//| + +STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { + uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; + uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; + uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; + common_hal__eve_Clear(EVEHAL(args[0]), c, s, t); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); + +//| .. method:: ClearStencil(s) +//| +//| Set clear value for the stencil buffer +//| +//| :param int s: value used when the stencil buffer is cleared. Range 0-255. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearStencil(EVEHAL(self), s); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); + +//| .. method:: ClearTag(s) +//| +//| Set clear value for the tag buffer +//| +//| :param int s: value used when the tag buffer is cleared. Range 0-255. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearTag(EVEHAL(self), s); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); + +//| .. method:: ColorA(alpha) +//| +//| Set the current color alpha +//| +//| :param int alpha: alpha for the current color. Range 0-255. The initial value is 255 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ColorA(EVEHAL(self), alpha); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); + +//| .. method:: ColorMask(r, g, b, a) +//| +//| Enable and disable writing of frame buffer color components +//| +//| :param int r: allow updates to the frame buffer red component. Range 0-1. The initial value is 1 +//| :param int g: allow updates to the frame buffer green component. Range 0-1. The initial value is 1 +//| :param int b: allow updates to the frame buffer blue component. Range 0-1. The initial value is 1 +//| :param int a: allow updates to the frame buffer alpha component. Range 0-1. The initial value is 1 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_ColorMask(EVEHAL(args[0]), r, g, b, a); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); + +//| .. method:: ColorRGB(red, green, blue) +//| +//| Set the drawing color +//| +//| :param int red: red value for the current color. Range 0-255. The initial value is 255 +//| :param int green: green for the current color. Range 0-255. The initial value is 255 +//| :param int blue: blue for the current color. Range 0-255. The initial value is 255 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ColorRGB(EVEHAL(args[0]), red, green, blue); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); + +//| .. method:: Display() +//| +//| End the display list +//| + +STATIC mp_obj_t _display(mp_obj_t self) { + + common_hal__eve_Display(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); + +//| .. method:: End() +//| +//| End drawing a graphics primitive +//| +//| :meth:`Vertex2ii` and :meth:`Vertex2f` calls are ignored until the next :meth:`Begin`. +//| + +STATIC mp_obj_t _end(mp_obj_t self) { + + common_hal__eve_End(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); + +//| .. method:: Jump(dest) +//| +//| Execute commands at another location in the display list +//| +//| :param int dest: display list address. Range 0-65535 +//| + +STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Jump(EVEHAL(self), dest); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); + +//| .. method:: LineWidth(width) +//| +//| Set the width of rasterized lines +//| +//| :param int width: line width in :math:`1/16` pixel. Range 0-4095. The initial value is 16 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { + uint32_t width = mp_obj_get_int_truncated(a0); + common_hal__eve_LineWidth(EVEHAL(self), width); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); + +//| .. method:: Macro(m) +//| +//| Execute a single command from a macro register +//| +//| :param int m: macro register to read. Range 0-1 +//| + +STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { + uint32_t m = mp_obj_get_int_truncated(a0); + common_hal__eve_Macro(EVEHAL(self), m); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); + +//| .. method:: Nop() +//| +//| No operation +//| + +STATIC mp_obj_t _nop(mp_obj_t self) { + + common_hal__eve_Nop(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); + +//| .. method:: PaletteSource(addr) +//| +//| Set the base address of the palette +//| +//| :param int addr: Address in graphics SRAM, 2-byte aligned. Range 0-4194303. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_PaletteSource(EVEHAL(self), addr); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); + +//| .. method:: PointSize(size) +//| +//| Set the radius of rasterized points +//| +//| :param int size: point radius in :math:`1/16` pixel. Range 0-8191. The initial value is 16 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { + uint32_t size = mp_obj_get_int_truncated(a0); + common_hal__eve_PointSize(EVEHAL(self), size); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); + +//| .. method:: RestoreContext() +//| +//| Restore the current graphics context from the context stack +//| + +STATIC mp_obj_t _restorecontext(mp_obj_t self) { + + common_hal__eve_RestoreContext(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); + +//| .. method:: Return() +//| +//| Return from a previous call command +//| + +STATIC mp_obj_t _return(mp_obj_t self) { + + common_hal__eve_Return(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); + +//| .. method:: SaveContext() +//| +//| Push the current graphics context on the context stack +//| + +STATIC mp_obj_t _savecontext(mp_obj_t self) { + + common_hal__eve_SaveContext(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); + +//| .. method:: ScissorSize(width, height) +//| +//| Set the size of the scissor clip rectangle +//| +//| :param int width: The width of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is hsize +//| :param int height: The height of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is 2048 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + common_hal__eve_ScissorSize(EVEHAL(self), width, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); + +//| .. method:: ScissorXY(x, y) +//| +//| Set the top left corner of the scissor clip rectangle +//| +//| :param int x: The :math:`x` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0 +//| :param int y: The :math:`y` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t x = mp_obj_get_int_truncated(a0); + uint32_t y = mp_obj_get_int_truncated(a1); + common_hal__eve_ScissorXY(EVEHAL(self), x, y); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); + +//| .. method:: StencilFunc(func, ref, mask) +//| +//| Set function and reference value for stencil testing +//| +//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7) +//| :param int ref: specifies the reference value for the stencil test. Range 0-255. The initial value is 0 +//| :param int mask: specifies a mask that is ANDed with the reference value and the stored stencil value. Range 0-255. The initial value is 255 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { + uint32_t func = mp_obj_get_int_truncated(args[1]); + uint32_t ref = mp_obj_get_int_truncated(args[2]); + uint32_t mask = mp_obj_get_int_truncated(args[3]); + common_hal__eve_StencilFunc(EVEHAL(args[0]), func, ref, mask); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); + +//| .. method:: StencilMask(mask) +//| +//| Control the writing of individual bits in the stencil planes +//| +//| :param int mask: the mask used to enable writing stencil bits. Range 0-255. The initial value is 255 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_StencilMask(EVEHAL(self), mask); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); + +//| .. method:: StencilOp(sfail, spass) +//| +//| Set stencil test actions +//| +//| :param int sfail: specifies the action to take when the stencil test fails, one of ``KEEP``, ``ZERO``, ``REPLACE``, ``INCR``, ``INCR_WRAP``, ``DECR``, ``DECR_WRAP``, and ``INVERT``. Range 0-7. The initial value is KEEP(1) +//| :param int spass: specifies the action to take when the stencil test passes, one of the same constants as **sfail**. Range 0-7. The initial value is KEEP(1) +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t sfail = mp_obj_get_int_truncated(a0); + uint32_t spass = mp_obj_get_int_truncated(a1); + common_hal__eve_StencilOp(EVEHAL(self), sfail, spass); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); + +//| .. method:: TagMask(mask) +//| +//| Control the writing of the tag buffer +//| +//| :param int mask: allow updates to the tag buffer. Range 0-1. The initial value is 1 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_TagMask(EVEHAL(self), mask); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); + +//| .. method:: Tag(s) +//| +//| Set the current tag value +//| +//| :param int s: tag value. Range 0-255. The initial value is 255 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_Tag(EVEHAL(self), s); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); + +//| .. method:: VertexTranslateX(x) +//| +//| Set the vertex transformation's x translation component +//| +//| :param int x: signed x-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { + uint32_t x = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateX(EVEHAL(self), x); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); + +//| .. method:: VertexTranslateY(y) +//| +//| Set the vertex transformation's y translation component +//| +//| :param int y: signed y-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + + +STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { + uint32_t y = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateY(EVEHAL(self), y); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); + +//| .. method:: VertexFormat(frac) +//| +//| Set the precision of vertex2f coordinates +//| +//| :param int frac: Number of fractional bits in X,Y coordinates, 0-4. Range 0-7. The initial value is 4 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { + uint32_t frac = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexFormat(EVEHAL(self), frac); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); + +//| .. method:: Vertex2ii(x, y, handle, cell) +//| +//| :param int x: x-coordinate in pixels. Range 0-511 +//| :param int y: y-coordinate in pixels. Range 0-511 +//| :param int handle: bitmap handle. Range 0-31 +//| :param int cell: cell number. Range 0-127 +//| +//| This method is an alternative to :meth:`Vertex2f`. +//| + +STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { + uint32_t x = mp_obj_get_int_truncated(args[1]); + uint32_t y = mp_obj_get_int_truncated(args[2]); + uint32_t handle = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 0; + uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; + common_hal__eve_Vertex2ii(EVEHAL(args[0]), x, y, handle, cell); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); + +#define N_METHODS 49 +#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) +#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } + +//} + +// Hand-written functions { + +//| .. method:: Vertex2f(b) +//| +//| Draw a point. +//| +//| :param float x: pixel x-coordinate +//| :param float y: pixel y-coordinate +//| STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { mp_float_t x = mp_obj_get_float(a0); mp_float_t y = mp_obj_get_float(a1); @@ -98,6 +922,40 @@ STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); +// Append an object x to the FIFO +#define ADD_X(self, x) \ + common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); + +//| .. method:: cmd0(n) +//| +//| Append the command word n to the FIFO +//| +//| :param int n: The command code +//| +//| This method is used by the ``eve`` module to efficiently add +//| commands to the FIFO. +//| + +STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { + uint32_t code = 0xffffff00 | mp_obj_get_int_truncated(n); + ADD_X(self, code); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); + +//| .. method:: cmd(n, fmt, args) +//| +//| Append a command packet to the FIFO. +//| +//| :param int n: The command code +//| :param str fmt: The command format `struct` layout +//| :param tuple args: The command's arguments +//| +//| Supported format codes: h, H, i, I. +//| +//| This method is used by the ``eve`` module to efficiently add +//| commands to the FIFO. +//| STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; mp_obj_t num = args[1]; diff --git a/shared-bindings/_eve/mod_eve-gen.h b/shared-bindings/_eve/mod_eve-gen.h deleted file mode 100644 index c5dafb16f020..000000000000 --- a/shared-bindings/_eve/mod_eve-gen.h +++ /dev/null @@ -1,382 +0,0 @@ - -STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t func = mp_obj_get_int_truncated(a0); - uint32_t ref = mp_obj_get_int_truncated(a1); - common_hal__eve_AlphaFunc(EVEHAL(self), func, ref); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); - -STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { - uint32_t prim = mp_obj_get_int_truncated(a0); - common_hal__eve_Begin(EVEHAL(self), prim); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); - -STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { - uint32_t fmt = mp_obj_get_int_truncated(a0); - common_hal__eve_BitmapExtFormat(EVEHAL(self), fmt); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); - -STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { - uint32_t handle = mp_obj_get_int_truncated(a0); - common_hal__eve_BitmapHandle(EVEHAL(self), handle); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); - -STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t linestride = mp_obj_get_int_truncated(a0); - uint32_t height = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapLayoutH(EVEHAL(self), linestride, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); - -STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { - uint32_t format = mp_obj_get_int_truncated(args[1]); - uint32_t linestride = mp_obj_get_int_truncated(args[2]); - uint32_t height = mp_obj_get_int_truncated(args[3]); - common_hal__eve_BitmapLayout(EVEHAL(args[0]), format, linestride, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); - -STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); - uint32_t height = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapSizeH(EVEHAL(self), width, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); - -STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { - uint32_t filter = mp_obj_get_int_truncated(args[1]); - uint32_t wrapx = mp_obj_get_int_truncated(args[2]); - uint32_t wrapy = mp_obj_get_int_truncated(args[3]); - uint32_t width = mp_obj_get_int_truncated(args[4]); - uint32_t height = mp_obj_get_int_truncated(args[5]); - common_hal__eve_BitmapSize(EVEHAL(args[0]), filter, wrapx, wrapy, width, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); - -STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - common_hal__eve_BitmapSource(EVEHAL(self), addr); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); - -STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - common_hal__eve_BitmapSwizzle(EVEHAL(args[0]), r, g, b, a); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); - -STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t a = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); - -STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t b = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); - -STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t c = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); - -STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t d = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); - -STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t e = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); - -STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t f = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); - -STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t src = mp_obj_get_int_truncated(a0); - uint32_t dst = mp_obj_get_int_truncated(a1); - common_hal__eve_BlendFunc(EVEHAL(self), src, dst); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); - -STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - common_hal__eve_Call(EVEHAL(self), dest); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); - -STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { - uint32_t cell = mp_obj_get_int_truncated(a0); - common_hal__eve_Cell(EVEHAL(self), cell); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); - -STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - common_hal__eve_ClearColorA(EVEHAL(self), alpha); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); - -STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - common_hal__eve_ClearColorRGB(EVEHAL(args[0]), red, green, blue); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); - -STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { - uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; - uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; - uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; - common_hal__eve_Clear(EVEHAL(args[0]), c, s, t); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); - -STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - common_hal__eve_ClearStencil(EVEHAL(self), s); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); - -STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - common_hal__eve_ClearTag(EVEHAL(self), s); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); - -STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - common_hal__eve_ColorA(EVEHAL(self), alpha); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); - -STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - common_hal__eve_ColorMask(EVEHAL(args[0]), r, g, b, a); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); - -STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - common_hal__eve_ColorRGB(EVEHAL(args[0]), red, green, blue); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); - -STATIC mp_obj_t _display(mp_obj_t self) { - - common_hal__eve_Display(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); - -STATIC mp_obj_t _end(mp_obj_t self) { - - common_hal__eve_End(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); - -STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - common_hal__eve_Jump(EVEHAL(self), dest); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); - -STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { - uint32_t width = mp_obj_get_int_truncated(a0); - common_hal__eve_LineWidth(EVEHAL(self), width); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); - -STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { - uint32_t m = mp_obj_get_int_truncated(a0); - common_hal__eve_Macro(EVEHAL(self), m); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); - -STATIC mp_obj_t _nop(mp_obj_t self) { - - common_hal__eve_Nop(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); - -STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - common_hal__eve_PaletteSource(EVEHAL(self), addr); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); - -STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { - uint32_t size = mp_obj_get_int_truncated(a0); - common_hal__eve_PointSize(EVEHAL(self), size); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); - -STATIC mp_obj_t _restorecontext(mp_obj_t self) { - - common_hal__eve_RestoreContext(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); - -STATIC mp_obj_t _return(mp_obj_t self) { - - common_hal__eve_Return(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); - -STATIC mp_obj_t _savecontext(mp_obj_t self) { - - common_hal__eve_SaveContext(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); - -STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); - uint32_t height = mp_obj_get_int_truncated(a1); - common_hal__eve_ScissorSize(EVEHAL(self), width, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); - -STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t x = mp_obj_get_int_truncated(a0); - uint32_t y = mp_obj_get_int_truncated(a1); - common_hal__eve_ScissorXY(EVEHAL(self), x, y); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); - -STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { - uint32_t func = mp_obj_get_int_truncated(args[1]); - uint32_t ref = mp_obj_get_int_truncated(args[2]); - uint32_t mask = mp_obj_get_int_truncated(args[3]); - common_hal__eve_StencilFunc(EVEHAL(args[0]), func, ref, mask); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); - -STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - common_hal__eve_StencilMask(EVEHAL(self), mask); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); - -STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t sfail = mp_obj_get_int_truncated(a0); - uint32_t spass = mp_obj_get_int_truncated(a1); - common_hal__eve_StencilOp(EVEHAL(self), sfail, spass); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); - -STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - common_hal__eve_TagMask(EVEHAL(self), mask); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); - -STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - common_hal__eve_Tag(EVEHAL(self), s); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); - -STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { - uint32_t x = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexTranslateX(EVEHAL(self), x); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); - -STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { - uint32_t y = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexTranslateY(EVEHAL(self), y); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); - -STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { - uint32_t frac = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexFormat(EVEHAL(self), frac); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); - -STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { - uint32_t x = mp_obj_get_int_truncated(args[1]); - uint32_t y = mp_obj_get_int_truncated(args[2]); - uint32_t handle = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 0; - uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; - common_hal__eve_Vertex2ii(EVEHAL(args[0]), x, y, handle, cell); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); -#define N_METHODS 49 -#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) -#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } From f101ff60c505f5ddcdd69cfd1f58e83c4676eb46 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 7 Feb 2020 17:10:19 -0800 Subject: [PATCH 11/15] Move _eve module declarations into shared-bindings header --- shared-bindings/_eve/__init__.c | 3 +- shared-bindings/_eve/__init__.h | 84 +++++++++++++++++++++++++++++++++ shared-module/_eve/__init__.h | 54 --------------------- 3 files changed, 86 insertions(+), 55 deletions(-) create mode 100644 shared-bindings/_eve/__init__.h diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index b398c0a5dd29..d3076afbfad9 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 James Bowman + * Copyright (c) 2020 James Bowman for Excamera Labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,6 +32,7 @@ #include "py/binary.h" #include "shared-module/_eve/__init__.h" +#include "shared-bindings/_eve/__init__.h" //| :mod:`_eve` --- low-level BridgeTek EVE bindings //| ================================================ diff --git a/shared-bindings/_eve/__init__.h b/shared-bindings/_eve/__init__.h new file mode 100644 index 000000000000..6287fb606ab6 --- /dev/null +++ b/shared-bindings/_eve/__init__.h @@ -0,0 +1,84 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 James Bowman for Excamera Labs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H + +void common_hal__eve_flush(common_hal__eve_t *eve); +void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf); +void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y); + +void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref); +void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim); +void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt); +void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle); +void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); +void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); +void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); +void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t); +void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Display(common_hal__eve_t *eve); +void common_hal__eve_End(common_hal__eve_t *eve); +void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width); +void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m); +void common_hal__eve_Nop(common_hal__eve_t *eve); +void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size); +void common_hal__eve_RestoreContext(common_hal__eve_t *eve); +void common_hal__eve_Return(common_hal__eve_t *eve); +void common_hal__eve_SaveContext(common_hal__eve_t *eve); +void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y); +void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask); +void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass); +void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x); +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y); +void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac); +void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H diff --git a/shared-module/_eve/__init__.h b/shared-module/_eve/__init__.h index f2fd7a943887..5217d860ab29 100644 --- a/shared-module/_eve/__init__.h +++ b/shared-module/_eve/__init__.h @@ -34,58 +34,4 @@ typedef struct _common_hal__eve_t { uint8_t buf[512]; // Command buffer } common_hal__eve_t; -void common_hal__eve_flush(common_hal__eve_t *eve); -void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf); -void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y); - -void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref); -void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim); -void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt); -void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle); -void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height); -void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height); -void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height); -void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); -void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); -void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); -void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); -void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); -void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); -void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); -void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); -void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); -void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); -void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); -void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); -void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha); -void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); -void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t); -void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s); -void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s); -void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha); -void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); -void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); -void common_hal__eve_Display(common_hal__eve_t *eve); -void common_hal__eve_End(common_hal__eve_t *eve); -void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest); -void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width); -void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m); -void common_hal__eve_Nop(common_hal__eve_t *eve); -void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr); -void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size); -void common_hal__eve_RestoreContext(common_hal__eve_t *eve); -void common_hal__eve_Return(common_hal__eve_t *eve); -void common_hal__eve_SaveContext(common_hal__eve_t *eve); -void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height); -void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y); -void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask); -void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask); -void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass); -void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask); -void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s); -void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x); -void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y); -void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac); -void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell); - #endif // MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H From 842fe54c83d9a2144cec592a3f8fcc519ab33d01 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 10 Feb 2020 18:35:25 -0800 Subject: [PATCH 12/15] remove no-longer-needed exclude --- conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conf.py b/conf.py index 4ea4ba4e8032..3b29986c0646 100644 --- a/conf.py +++ b/conf.py @@ -156,7 +156,6 @@ "ports/zephyr", "py", "shared-bindings/util.*", - "shared-bindings/_eve/mod_eve-gen.h", "shared-module", "supervisor", "tests", From 1f44029c560bef1fc3ce140ebe10512ed378561c Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 10 Feb 2020 18:57:04 -0800 Subject: [PATCH 13/15] Remove unused code --- shared-bindings/_eve/__init__.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index d3076afbfad9..8ea9d033f22e 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -900,8 +900,6 @@ STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); -#define N_METHODS 49 -#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) #define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } //} @@ -1023,12 +1021,6 @@ STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(_EVE_locals_dict, _EVE_locals_dict_table); -STATIC void _EVE_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)self_in; - (void)kind; - mp_printf(print, "<_EVE>"); -} - STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); @@ -1040,11 +1032,8 @@ STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp STATIC const mp_obj_type_t _EVE_type = { { &mp_type_type }, - // Save on qstr's, reuse same as for module .name = MP_QSTR__EVE, - .print = _EVE_print, .make_new = _EVE_make_new, - // .attr = _EVE_attr, .locals_dict = (void*)&_EVE_locals_dict, }; From a87dee2f66732690bde509e7d1221cce4c1fb466 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 10 Feb 2020 19:34:38 -0800 Subject: [PATCH 14/15] Correct the BitmapTransform operations. Correct argument order better argument naming fix copypaste bug on C and F arguments --- shared-bindings/_eve/__init__.c | 58 +++++++++++++++------------ shared-bindings/_eve/__init__.h | 12 +++--- shared-module/_eve/__init__.c | 71 +++++++++++++++++++++++++++------ 3 files changed, 97 insertions(+), 44 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 8ea9d033f22e..97b4e8c47964 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -268,13 +268,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizz //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`a` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 //| +//| The initial value is **p** = 0, **v** = 256. This represents the value 1.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t a = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformA(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); @@ -286,33 +288,34 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`b` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 //| +//| The initial value is **p** = 0, **v** = 0. This represents the value 0.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t b = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformB(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); -//| .. method:: BitmapTransformC(c) +//| .. method:: BitmapTransformC(v) //| //| Set the :math:`c` component of the bitmap transform matrix //| -//| :param int c: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| :param int v: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 //| //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| -STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t c = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0) { + uint32_t v = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapTransformC(EVEHAL(self), v); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc); //| .. method:: BitmapTransformD(p, v) //| @@ -321,13 +324,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`d` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 //| +//| The initial value is **p** = 0, **v** = 0. This represents the value 0.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t d = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformD(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); @@ -339,33 +344,34 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`e` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 //| +//| The initial value is **p** = 0, **v** = 256. This represents the value 1.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t e = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformE(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); -//| .. method:: BitmapTransformF(f) +//| .. method:: BitmapTransformF(v) //| //| Set the :math:`f` component of the bitmap transform matrix //| -//| :param int f: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| :param int v: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 //| //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| -STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t f = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0) { + uint32_t v = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapTransformF(EVEHAL(self), v); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformf_obj, _bitmaptransformf); //| .. method:: BlendFunc(src, dst) //| diff --git a/shared-bindings/_eve/__init__.h b/shared-bindings/_eve/__init__.h index 6287fb606ab6..759a629bbddb 100644 --- a/shared-bindings/_eve/__init__.h +++ b/shared-bindings/_eve/__init__.h @@ -41,12 +41,12 @@ void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_ void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); -void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); -void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); -void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); -void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); -void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); -void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t v); +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t v); void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c index ca6fd4031b43..2c93eb69f703 100644 --- a/shared-module/_eve/__init__.c +++ b/shared-module/_eve/__init__.c @@ -80,190 +80,237 @@ void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t r C4(eve, ((9 << 24) | ((func & 7) << 8) | ((ref & 255)))); } + void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim) { C4(eve, ((31 << 24) | ((prim & 15)))); } + void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt) { C4(eve, ((46 << 24) | (fmt & 65535))); } + void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle) { C4(eve, ((5 << 24) | ((handle & 31)))); } + void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height) { C4(eve, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3)))); } + void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height) { C4(eve, ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511)))); } + void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height) { C4(eve, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3)))); } + void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height) { C4(eve, ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511)))); } + void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr) { C4(eve, ((1 << 24) | ((addr & 0xffffff)))); } + void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { C4(eve, ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7)))); } -void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p) { - C4(eve, ((21 << 24) | ((p & 1) << 17) | ((a & 131071)))); + +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((21 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p) { - C4(eve, ((22 << 24) | ((p & 1) << 17) | ((b & 131071)))); + +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((22 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p) { - C4(eve, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215)))); + +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t v) { + C4(eve, ((23 << 24) | ((v & 16777215)))); } -void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p) { - C4(eve, ((24 << 24) | ((p & 1) << 17) | ((d & 131071)))); + +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((24 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p) { - C4(eve, ((25 << 24) | ((p & 1) << 17) | ((e & 131071)))); + +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((25 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p) { - C4(eve, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215)))); + +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t v) { + C4(eve, ((26 << 24) | ((v & 16777215)))); } + void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst) { C4(eve, ((11 << 24) | ((src & 7) << 3) | ((dst & 7)))); } + void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest) { C4(eve, ((29 << 24) | ((dest & 65535)))); } + void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell) { C4(eve, ((6 << 24) | ((cell & 127)))); } + void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha) { C4(eve, ((15 << 24) | ((alpha & 255)))); } + void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { C4(eve, ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); } + void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t) { C4(eve, ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1)))); } + void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s) { C4(eve, ((17 << 24) | ((s & 255)))); } + void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s) { C4(eve, ((18 << 24) | ((s & 255)))); } + void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha) { C4(eve, ((16 << 24) | ((alpha & 255)))); } + void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { C4(eve, ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1)))); } + void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { C4(eve, ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); } + void common_hal__eve_Display(common_hal__eve_t *eve) { C4(eve, ((0 << 24))); } + void common_hal__eve_End(common_hal__eve_t *eve) { C4(eve, ((33 << 24))); } + void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest) { C4(eve, ((30 << 24) | ((dest & 65535)))); } + void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width) { C4(eve, ((14 << 24) | ((width & 4095)))); } + void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m) { C4(eve, ((37 << 24) | ((m & 1)))); } + void common_hal__eve_Nop(common_hal__eve_t *eve) { C4(eve, ((45 << 24))); } + void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr) { C4(eve, ((42 << 24) | (((addr) & 4194303)))); } + void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size) { C4(eve, ((13 << 24) | ((size & 8191)))); } + void common_hal__eve_RestoreContext(common_hal__eve_t *eve) { C4(eve, ((35 << 24))); } + void common_hal__eve_Return(common_hal__eve_t *eve) { C4(eve, ((36 << 24))); } + void common_hal__eve_SaveContext(common_hal__eve_t *eve) { C4(eve, ((34 << 24))); } + void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height) { C4(eve, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095)))); } + void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y) { C4(eve, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047)))); } + void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask) { C4(eve, ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255)))); } + void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask) { C4(eve, ((19 << 24) | ((mask & 255)))); } + void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass) { C4(eve, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7)))); } + void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask) { C4(eve, ((20 << 24) | ((mask & 1)))); } + void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s) { C4(eve, ((3 << 24) | ((s & 255)))); } + void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x) { C4(eve, ((43 << 24) | (((x) & 131071)))); } + void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y) { C4(eve, ((44 << 24) | (((y) & 131071)))); } + void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell) { C4(eve, ((2 << 30) | (((x) & 511) << 21) | (((y) & 511) << 12) | (((handle) & 31) << 7) | (((cell) & 127) << 0))); } From b02937d1a7ed0221778adc4719256344a4be2d0d Mon Sep 17 00:00:00 2001 From: James Bowman Date: Thu, 13 Feb 2020 07:28:21 -0800 Subject: [PATCH 15/15] Split ROMDECLS for readability --- shared-bindings/_eve/__init__.c | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 97b4e8c47964..9bc790f5d1fd 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -906,7 +906,56 @@ STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); -#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } +#define ROM_DECLS \ + { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } //}