gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit a43431929183329abbfea5a8c08ab577e9fa14b2 parent 4609d285538b3a64b37ee5a34fea0a1ad012f798 Author: Toxa <56631470+untoxa@users.noreply.github.com> Date: Fri, 9 Sep 2022 18:16:50 +0300 Merge pull request #410 from michel-iwaniec/sms_rle_map SMS: Enable rle_map example for sms Diffstat:
| M | gbdk-lib/examples/cross-platform/rle_map/Makefile | 2 | +- |
| M | gbdk-lib/examples/cross-platform/rle_map/src/main.c | 23 | +++++++++++++++-------- |
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/gbdk-lib/examples/cross-platform/rle_map/Makefile b/gbdk-lib/examples/cross-platform/rle_map/Makefile @@ -9,7 +9,7 @@ LCC = $(GBDK_HOME)bin/lcc # They can also be built/cleaned individually: "make gg" and "make gg-clean" # Possible are: gb gbc pocket megaduck sms gg #TARGETS=gb pocket sms gg -TARGETS=gb gg +TARGETS=gb gg sms # Configure platform specific LCC flags here: LCCFLAGS_gb = -Wl-yt0x19 -Wl-yo4 -Wm-yS -Wm-yn"$(PROJECTNAME)" diff --git a/gbdk-lib/examples/cross-platform/rle_map/src/main.c b/gbdk-lib/examples/cross-platform/rle_map/src/main.c @@ -20,7 +20,13 @@ uint8_t scrollpos = 0; // Scroll position in pixels uint8_t datapos = 0; // x position in tiles inside the collision map void main() { - + if(DEVICE_SCREEN_BUFFER_WIDTH == DEVICE_SCREEN_WIDTH) + { + // On platforms where screen buffer has no more space than physical screen, + // the next map column will be written to the leftmost screen column. + // So we blank the leftmost column to hide visual artifacts where possible. + HIDE_LEFT_COLUMN; + } SHOW_BKG; // Load Tile data @@ -32,16 +38,18 @@ void main() { // To get started, decompress and display a whole screen worth, // + 1 additional column in the direction being scrolled (to // avoid screen tearing from drawing a column right as it scrolls into view) - for (uint8_t i = 0; (rle_decompress(data, MAP_DATA_HEIGHT)) && (i != DEVICE_SCREEN_WIDTH + 1); i++) { + for (uint8_t i = 0; (i != DEVICE_SCREEN_WIDTH + 1); i++) { + rle_decompress(data, MAP_DATA_HEIGHT); // pre-process column here // ... // Draw current column starting at row 0 - set_bkg_tiles(i, 0, 1, MAP_DATA_HEIGHT, data); + set_bkg_tiles(i & (DEVICE_SCREEN_BUFFER_WIDTH-1), 0, 1, MAP_DATA_HEIGHT, data); } // main game loop - datapos = scrollpos = 0; + datapos = 0; + scrollpos = 1; while(TRUE) { wait_vbl_done(); @@ -54,13 +62,12 @@ void main() { // Once for every 8 pixels scrolled: draw a // new column of tiles on the right-most edge - // ( == 1 is used here so it triggers on the very first pass) - if ((scrollpos & 0x07u) == 1) { + if ((scrollpos & 0x07u) == 0) { // Get hardware map tile X column from scroll position / 8 // Then + 1 since there's a 1 tile column buffer on the right edge - datapos = (scrollpos >> 3) + 1; - uint8_t map_x_column = (datapos + DEVICE_SCREEN_WIDTH) & 31; + datapos = (scrollpos >> 3); + uint8_t map_x_column = (datapos + DEVICE_SCREEN_WIDTH) & (DEVICE_SCREEN_BUFFER_WIDTH-1); // Decompress a column worth of data // If the end of compressed data is reached, reset decompression
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.