gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 2366cfde7217bdea369cd005f45a692ef40a0d17 parent 21b1f9bc50bcd991b876f8d24aebea1abfefe902 Author: Toxa <untoxa@mail.ru> Date: Tue, 20 Feb 2024 22:36:28 +0300 EXAMPLES: GB Printer: image centering Diffstat:
| M | gbdk-lib/examples/gb/gbprinter/src/gbprinter.c | 4 | ++-- |
| M | gbdk-lib/examples/gb/gbprinter/src/gbprinter.h | 2 | +- |
| M | gbdk-lib/examples/gb/gbprinter/src/print_example.c | 2 | +- |
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gbdk-lib/examples/gb/gbprinter/src/gbprinter.c b/gbdk-lib/examples/gb/gbprinter/src/gbprinter.c @@ -95,7 +95,7 @@ uint8_t gbprinter_detect(uint8_t delay) { return printer_wait(delay, PRN_STATUS_MASK_ANY, PRN_STATUS_OK); } -uint8_t gbprinter_print_image(const uint8_t * image_map, const uint8_t * image, uint8_t pos_x, uint8_t width, uint8_t height) { +uint8_t gbprinter_print_image(const uint8_t * image_map, const uint8_t * image, int8_t pos_x, uint8_t width, uint8_t height) { static const uint8_t * img; static uint8_t error; @@ -108,7 +108,7 @@ uint8_t gbprinter_print_image(const uint8_t * image_map, const uint8_t * image, printer_tile_num = 0; for (uint8_t y = 0; y != rows; y++) { - for (uint8_t x = 0; x != PRN_TILE_WIDTH; x++) { + for (int16_t x = 0; x != PRN_TILE_WIDTH; x++) { // overlay the picture tile if in range if ((y < height) && (x >= pos_x) && (x < (pos_x + width))) { uint8_t tile = image_map[(y * width) + (x - pos_x)]; diff --git a/gbdk-lib/examples/gb/gbprinter/src/gbprinter.h b/gbdk-lib/examples/gb/gbprinter/src/gbprinter.h @@ -139,6 +139,6 @@ inline void gbprinter_set_print_params(uint8_t margins, uint8_t palette, uint8_t } uint8_t gbprinter_detect(uint8_t delay); -uint8_t gbprinter_print_image(const uint8_t * image_map, const uint8_t * image, uint8_t pos_x, uint8_t width, uint8_t height); +uint8_t gbprinter_print_image(const uint8_t * image_map, const uint8_t * image, int8_t pos_x, uint8_t width, uint8_t height); #endif diff --git a/gbdk-lib/examples/gb/gbprinter/src/print_example.c b/gbdk-lib/examples/gb/gbprinter/src/print_example.c @@ -18,7 +18,7 @@ void main(void) { waitpad(J_A); if (gbprinter_detect(PRINTER_DETECT_TIMEOUT) == PRN_STATUS_OK) { if (gbprinter_print_image(scene00001_map, scene00001_tiles, - 0, + (PRN_TILE_WIDTH - (scene00001_WIDTH / scene00001_TILE_W)) / 2, (scene00001_WIDTH / scene00001_TILE_W), (scene00001_HEIGHT / scene00001_TILE_H)) == PRN_STATUS_OK) { puts("Printed OK!"); } else {
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.