Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfcbb36

Browse files
authored
Merge pull request #667 from python-ugame/2.x
_stage: use 16 bit for coordinates to support larger screens
2 parents 5f326ac + f10be55 commit cfcbb36

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

shared-bindings/_stage/__init__.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@
7171
//| This function is intended for internal use in the ``stage`` library
7272
//| and all the necessary checks are performed there.
7373
STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
74-
uint8_t x0 = mp_obj_get_int(args[0]);
75-
uint8_t y0 = mp_obj_get_int(args[1]);
76-
uint8_t x1 = mp_obj_get_int(args[2]);
77-
uint8_t y1 = mp_obj_get_int(args[3]);
74+
uint16_t x0 = mp_obj_get_int(args[0]);
75+
uint16_t y0 = mp_obj_get_int(args[1]);
76+
uint16_t x1 = mp_obj_get_int(args[2]);
77+
uint16_t y1 = mp_obj_get_int(args[3]);
7878

7979
size_t layers_size = 0;
8080
mp_obj_t *layers;

shared-module/_stage/Layer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
// Get the color of the pixel on the layer.
32-
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y) {
32+
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) {
3333

3434
// Shift by the layer's position offset.
3535
x -= layer->x;

shared-module/_stage/Layer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ typedef struct {
4343
uint8_t rotation;
4444
} layer_obj_t;
4545

46-
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y);
46+
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y);
4747

4848
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER

shared-module/_stage/Text.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
// Get the color of the pixel on the text.
32-
uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y) {
32+
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) {
3333

3434
// Shift by the text's position offset.
3535
x -= text->x;

shared-module/_stage/Text.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ typedef struct {
4141
uint8_t width, height;
4242
} text_obj_t;
4343

44-
uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y);
44+
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y);
4545

4646
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT

shared-module/_stage/__init__.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,14 @@
3131
#include "shared-bindings/_stage/Text.h"
3232

3333

34-
bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
34+
bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
3535
mp_obj_t *layers, size_t layers_size,
3636
uint16_t *buffer, size_t buffer_size,
3737
busio_spi_obj_t *spi) {
3838

39-
// TODO(deshipu): Do a collision check of each layer with the
40-
// rectangle, and only process the layers that overlap with it.
41-
4239
size_t index = 0;
43-
for (uint8_t y = y0; y < y1; ++y) {
44-
for (uint8_t x = x0; x < x1; ++x) {
40+
for (uint16_t y = y0; y < y1; ++y) {
41+
for (uint16_t x = x0; x < x1; ++x) {
4542
for (size_t layer = 0; layer < layers_size; ++layer) {
4643
uint16_t c = TRANSPARENT;
4744
layer_obj_t *obj = MP_OBJ_TO_PTR(layers[layer]);

shared-module/_stage/__init__.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#define TRANSPARENT (0x1ff8)
3636

37-
bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
37+
bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
3838
mp_obj_t *layers, size_t layers_size,
3939
uint16_t *buffer, size_t buffer_size,
4040
busio_spi_obj_t *spi);

0 commit comments

Comments
 (0)