• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Graphics] [pokeemerald] Problem with World Map (512 tiles)

8
Posts
6
Years
    • Seen Nov 22, 2022
    Hi guys.

    I was trying to insert a World Map composed by more than 256 tiles.
    In order to do that, I decided to separate the map in two maps: One for the background, and the second one for the front layout:
    [pokeemerald] Problem with World Map (512 tiles)


    Spoiler:


    My original ideas was use the bg3 to be the background and the bg2 to be the layout.

    To do that I added a new element of sFieldRegionMapBgTemplates in field_region_map.c

    Code:
        {
            .bg = 3,
            .charBaseIndex = 1,
            .mapBaseIndex = 26,
            .screenSize = 2,
            .paletteMode = 1,
            .priority = 2,
            .baseTile = 0
        }

    This new map will use the charBaseIndex 1 and the mapBaseIndex 26

    Then in the function FieldUpdateRegionMap() I just had to add this line: ShowBg(3);

    Code:
            case 2:
                SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
                ShowBg(0);
                ShowBg(2);
    +++++ ShowBg(3);
                sFieldRegionMapHandler->state++;
                break;

    Aditionally in region_map.c I uploaded the new background as sRegionMapBg_GfxLZ2 and the raw map as sRegionMapBg_TilemapLZ2


    Then I modified the function LoadRegionMapGfx() in order to force the use of this new tileset and map in the char- and mapBaseIndex (1 and 26):

    Code:
    bool8 LoadRegionMapGfx(void)
    {
        switch (gRegionMap->initStep)
        {
        case 0:
            if (gRegionMap->bgManaged){
                DecompressAndCopyTileDataToVram(gRegionMap->bgNum, sRegionMapBg_GfxLZ, 0, 0, 0);
    +++++ DecompressAndCopyTileDataToVram(3, sRegionMapBg_GfxLZ2, 0, 0, 0);
                }
            else{
                LZ77UnCompVram(sRegionMapBg_GfxLZ, (u16 *)BG_CHAR_ADDR(2));
    +++++ LZ77UnCompVram(sRegionMapBg_GfxLZ2, (u16 *)BG_CHAR_ADDR(1));}
            break;
        case 1:
            if (gRegionMap->bgManaged)
            {
                if (!FreeTempTileDataBuffersIfPossible()){
                    DecompressAndCopyTileDataToVram(gRegionMap->bgNum, sRegionMapBg_TilemapLZ, 0, 0, 1);
    +++++++ DecompressAndCopyTileDataToVram(3, sRegionMapBg_TilemapLZ2, 0, 0, 1);                
                    }
            }
            else
            {
                LZ77UnCompVram(sRegionMapBg_TilemapLZ, (u16 *)BG_SCREEN_ADDR(28));
    +++++ LZ77UnCompVram(sRegionMapBg_TilemapLZ2, (u16 *)BG_SCREEN_ADDR(26));
            }
            break;

    I compiled the project and I got this map:

    [pokeemerald] Problem with World Map (512 tiles)


    Spoiler:


    Apparently, Bg3 was mapped effectively but it appears invisible :( (But appears in the MapViewer), also the tileset seems to be well inserted and not overlapped (the bug tiles between the two tilesets are just bc the background tileset is smaller than 128x128)

    Then I realized that perhaps the problem could be in field_region_map.c when the Bgs are initialized:
    Code:
    InitBgsFromTemplates(1, sFieldRegionMapBgTemplates, ARRAY_COUNT(sFieldRegionMapBgTemplates));

    I don't understand how this bg-thingys work (black magic??). But when I changed that 1 to a 2 I got a beauty map composed by 512 tiles... The only problem... I destroyed the Bg0 including the name of the region and route:

    [pokeemerald] Problem with World Map (512 tiles)


    Spoiler:

    But now is the Bg0 which don't want to be shown...

    I know I am playing with fire and go beyond the specifications of the GBA... but, any idea???

    Thanks a lot!
     
    453
    Posts
    6
    Years
    • Seen yesterday
    The first argument of InitBgsFromTemplates seems to be the graphics mode number.
    In mode 1 backgrounds 0, 1 & 2 are available while in mode 2 only bgs 2 & 3 are usable.

    Loading your new background as BG1 in mode 1 might work, but you wouldn't be able to apply affine transformations to it (since only BG2 is transformable in mode 1).
     
    8
    Posts
    6
    Years
    • Seen Nov 22, 2022
    The first argument of InitBgsFromTemplates seems to be the graphics mode number.
    In mode 1 backgrounds 0, 1 & 2 are available while in mode 2 only bgs 2 & 3 are usable.

    Loading your new background as BG1 in mode 1 might work, but you wouldn't be able to apply affine transformations to it (since only BG2 is transformable in mode 1).

    Thanks a lot for your answer.

    Indeed now the three bg appears. But the problem now is that the Bg1 appears to have a different dimension and is broken (use a random tileset composed for both tilesets)
    [pokeemerald] Problem with World Map (512 tiles)

    [pokeemerald] Problem with World Map (512 tiles)


    Is there an additional step to do this?
     
    453
    Posts
    6
    Years
    • Seen yesterday
    Since it's a non-affine background, the tilemap format is different and so is the meaning of the .screenSize value
    EDIT: If you're planning on making the region map non-affine, do you even need 2 backgrounds? The 256 tile limit only applies to affine backgrounds.
     
    8
    Posts
    6
    Years
    • Seen Nov 22, 2022
    Since it's a non-affine background, the tilemap format is different and so is the meaning of the .screenSize value
    EDIT: If you're planning on making the region map non-affine, do you even need 2 backgrounds? The 256 tile limit only applies to affine backgrounds.

    Thanks a lot, now it works!!!

    Is sad that now I can't do affine functions (for example, the zoom in Pokenav) but it is something

    [pokeemerald] Problem with World Map (512 tiles)
     
    Back
    Top