Trying to load big map

SGDK only sub forum

Moderator: Stef

Post Reply
vnsbr
Interested
Posts: 48
Joined: Sun Dec 17, 2017 4:13 pm

Trying to load big map

Post by vnsbr » Tue Mar 17, 2020 11:32 am

Hello I am trying to load a big map (8192x224) but currently getting a black screen(no erros or anything). Is there a limit on how much you can load? I got it to work trimming to half the size 4096px. I read that there is a limit about unique tiles(1200), but i dont think that limit is even close since it is a limited tile set - anyway to check if that is the case?.

here is the resource code, i have removed debug functions to simplify, but none return any errors besides currentMap returning 0 when i try to load the big map.

my metatiles are 32x32px, is there anyway i can load tileset and tilemap separated? maybe that way i could save some RAM (224x7 metatiles in this map - then i could map each metatile to individual 8x8 hardware tiles).

code:

Code: Select all

IMAGE level1a "gfx/Dark Wood Demo Foreground.png" NONE
and the loading code:

Code: Select all

#include <genesis.h>
#include "gfx.h"

u16 allPaletteValues[64];
Map *currentMap;

void SetPalette(u16 paletteIndex, const u16* palette)
{
    int loop = 0;
    for (loop = 0; loop < 16; loop++)
    {
        allPaletteValues[loop + (paletteIndex << 4)] = palette[loop];
    }    
}

void FadeIn(u16 time)
{
    VDP_fadeInAll(allPaletteValues, time, 1);
}

int main()
{
    currentMap = unpackMap(level1a.map, NULL);
    u16 index = TILE_USERINDEX;

    SYS_disableInts();
    VDP_loadTileSet(level1a.tileset, index, TRUE);
    VDP_setMapEx(PLAN_A, currentMap, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, index), 0, 0, 0, 0, planWidth, planHeight);
    SetPalette(PAL0, level1a.palette->data);
    SYS_enableInts();

    index += level1a.tileset->numTile;
    FadeIn(10);

    while (TRUE)
    {
        VDP_waitVSync();
    }
    return 0;
}
thanks!

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Trying to load big map

Post by Chilly Willy » Tue Mar 17, 2020 1:38 pm

You're trying to use a compressed map. Unpacking the map requires a word for every cell of the map. Given the size you mention, this will try to allocate 56KB of ram. Sounds like you don't have that much ram available. If you really need the big maps, maybe leave them uncompressed and use straight from rom rather than decompressing into ram.

vnsbr
Interested
Posts: 48
Joined: Sun Dec 17, 2017 4:13 pm

Re: Trying to load big map

Post by vnsbr » Tue Mar 17, 2020 2:28 pm

Chilly Willy wrote:
Tue Mar 17, 2020 1:38 pm
You're trying to use a compressed map. Unpacking the map requires a word for every cell of the map. Given the size you mention, this will try to allocate 56KB of ram. Sounds like you don't have that much ram available. If you really need the big maps, maybe leave them uncompressed and use straight from rom rather than decompressing into ram.
thanks @Chilly, how to leave it uncompressed though? i guess that it has nothing to do with NONE parameter then.

staying in ROM would be better but im afraid id have to code custom functions to draw from there?

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Trying to load big map

Post by Chilly Willy » Tue Mar 17, 2020 8:34 pm

It would need to be in Map struct format in rom. Then instead of setting currentMap from the unpackMap() function, you'd set it to where it is in rom instead.

Code: Select all

currentMap = unpackMap(level1a.map, NULL);
would change to something like

Code: Select all

currentMap = (Map *)&level1a_map;
where level1a_map is the uncompressed map embedded in the rom as const data.

Post Reply