- 8
- Posts
- 7
- 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:
LAYOUT:
BACKGROUND:
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
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);
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):
I compiled the project and I got this map:
MapViewer:
FrameInspector (Hiding bg0 and bg2)
Tiles:
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:
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:
Now the Map viewer shows this monstrosity
The tileset is not destroyed:
It even changes in real-time when I move the cursor to a city.
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!
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:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/IAvaD8R.png)
Spoiler:
LAYOUT:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/dHQ97UB.png)
BACKGROUND:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/c0bxyJR.png)
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:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/TN3BQ6D.png)
Spoiler:
MapViewer:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/1g8u5O8.png)
FrameInspector (Hiding bg0 and bg2)
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/V43d37c.png)
Tiles:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/6sz8ZCf.png)
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:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/Mxgpjmd.png)
Spoiler:
Now the Map viewer shows this monstrosity
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/zXOZiec.png)
The tileset is not destroyed:
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/bM9ALwz.png)
It even changes in real-time when I move the cursor to a city.
![[PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles) [PokeCommunity.com] [pokeemerald] Problem with World Map (512 tiles)](https://i.imgur.com/K36X9HL.png)
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!