Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-12-30 12:24:02

Wild
New member
From: The Land Down Under
Registered: 2016-12-30
Post 1/9

[Pokered] Expanding Tilesets

Hi Everyone,

I've been a long time observer of this forum and have found it useful beyond expectation over the years, so thank you to everyone on here for creating such a vibrant community and resource for information.

Now I would like to ask a question for myself, relating to expanding tilesets in Red/Blue.

My goal was to add a further 16 tiles to the overworld tileset, thus making a new row in the png file and allowing a bit more detail ingame. Example shown below using the large tree from the forest tileset.

overworld_t2.png

I succeeded in doing this, and modifying the overworld blockset so that my new tiles could be used, and then modified the Pallet Town map to include the tiles using RB Map. To this point all works properly:

Screen_Shot_2016_12_30_at_7_57_28_PM.png

However, in game, things aren't looking too flash.

Screen_Shot_2016_12_30_at_10_30_45_PM.png

As you can see, instead of the tree we're getting tiles from the font. The tile ID of the first new tile in the new row is 0x60, throwing out 'A' and so forth for subsequent tiles.

Of course, this is happening because the font is stored in the RAM directly after the tileset, presumedly 60 bytes after the beginning of the tileset. Has anybody here successfully shifted things around to allow for expanded tilesets in Red/Blue?

I seem to remember reading something a long time ago about a 255 tileset hack for Gold/Silver, and assuming the graphical data is stored in the RAM the same way, could a similar method be applied?

Danny-E 33 if you're reading this, Shanty Town mentions in his thread about RB Map that it supports up to 255 tile tilesets like in Pokemon Prototype. Would you mind sharing how you did it?

Thanks for reading and for your help!

Last edited by Wild (2016-12-30 13:35:02)

Offline

#2 2016-12-30 20:40:05

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,007/1,021

Re: [Pokered] Expanding Tilesets

ShantyTown must have misspoke. My hack uses 256 block blocksets, not 256 tile tilesets.

However, you can fit in about 25 extra tiles into the ow tileset.

rzKEPQx.png

Here you see that the font is actually not right after the tileset. Those tiles after the tileset (and the tiles you see in your screenshot) are unused tiles; a few letters, a few garbage tiles, a few punctuation, and a few japanese characters.

In my image above, I have outlined the unused tiles in red. These are part of gfx/text_box.png.
The only tile that I know of that is used from that set is the colon, outlined in green.
It is not the ordinary colon that is part of the font. This colon is used when viewing the trainer card and when saving. It is used to display play time. However, on the trainer card, it is loaded separately so you don't even need to worry about it.
The only thing you have to worry about is during saving. If you want to use that space for additional tileset tiles, you have to move that special colon tile somewhere else so that it is displayed correctly during saving. I recommend moving it to one of the unused tiles in the font. I have outlined those in blue.

Once you have done that, you just have to tweak how TextBoxGraphics is loaded in the LoadTextBoxTilePatterns:: routine in home.asm
Change LoadTextBoxTilePatterns:: from this:

LoadTextBoxTilePatterns::
    ld a, [rLCDC]
    bit 7, a ; is the LCD enabled?
    jr nz, .on
.off
    ld hl, TextBoxGraphics
    ld de, vChars2 + $600
    ld bc, TextBoxGraphicsEnd - TextBoxGraphics
    ld a, BANK(TextBoxGraphics)
    jp FarCopyData2 ; if LCD is off, transfer all at once
.on
    ld de, TextBoxGraphics
    ld hl, vChars2 + $600
    lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10
    jp CopyVideoData ; if LCD is on, transfer during V-blank

To this:

LoadTextBoxTilePatterns::
    ld a, [rLCDC]
    bit 7, a ; is the LCD enabled?
    jr nz, .on
.off
    ld hl, TextBoxGraphics + $190
    ld de, vChars2 + $790
    ld bc, TextBoxGraphicsEnd - TextBoxGraphics - $190
    ld a, BANK(TextBoxGraphics)
    jp FarCopyData2 ; if LCD is off, transfer all at once
.on
    ld de, TextBoxGraphics + $190
    ld hl, vChars2 + $790
    lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10 - $19
    jp CopyVideoData ; if LCD is on, transfer during V-blank

This basically skips the first $19 tiles of that graphics file, and loads the remaining tiles $19 tiles further in to memory (so that they are actually at the same place as they always were).

Then those first $19 (25) tiles are free to use at the end of the tileset.

I'm almost certain those other punctuation tiles (singles quotes, double quotes, ellipsis) are entirely unused, but I could be wrong. If you discover that some of those tiles were used, just move them into the normal font, like you did with the special colon.


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#3 2016-12-30 21:11:14

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,008/1,021

Re: [Pokered] Expanding Tilesets

To test that this all worked, I changed gfx/tilesets/overworld.t2.png to a 128x64 pixel image, and renamed it to overworld.t7.png (the 't' value represents the number of blank tiles that need to be ignored at the end of the last row).

This caused bank $19 to be too large, so I moved Overworld_GFX and Overworld_Block from bank $19 to the first empty bank (bank $2d).

Lastly, in home/overworld.asm, in LoadTilesetTilePatternData:: I changed `ld bc,$600` to `ld bc,$790` to load an extra 25 tiles when the tileset is loaded.

Here is the result:
Pc3oBcH.png


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#4 2016-12-31 03:04:28

Wild
New member
From: The Land Down Under
Registered: 2016-12-30
Post 2/9

Re: [Pokered] Expanding Tilesets

Many thanks for your reply Danny, it was very useful. I did however turn out some interesting effects by expanding the tileset by 25 tiles. This ended up displaying a lot of junk tiles all over the place, including in the intro and all over the overworld when bringing up the start menu, talking to a NPC etc.

I scaled this back to add only the 12 new tiles I had added (size $C0) and this seemed to work a lot more smoothly, however when accessing the party menu, and going back out, parts of the HP bar are now drawn across the newly added tiles:

Screen_Shot_2016_12_31_at_1_07_47_PM.png

I have had a look around in the party_menu.asm, also at the DrawHPBar functions, but can't find anything that will allow me to shift where in the RAM the HP tiles are loaded. (Of course, it's there somewhere, I just can't see it.)

Would adding a line of code in the right place to reload the current tileset when leaving the party menu fix this issue? I have gone through party_menu.asm and looked for a suitable place to call LoadTilesetTilePatternData but the only place I found under '.done' garbled both the HP bar and didn't quite fix the tiles in the overworld anyway.

Any ideas? Relating both to the 25 tile expansion causing major glitches and working around the HP bar drawing issue?

Many thanks, I look forward to your comments.

EDIT: Curiously, when opening and closing the Trainer menu, this reloads and fixes the glitched graphics...

Last edited by Wild (2016-12-31 03:15:44)

Offline

#5 2016-12-31 03:20:12

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,010/1,021

Re: [Pokered] Expanding Tilesets

Ah.
So you might have noticed that entering the Pokedex and exiting didn't cause any graphical bugs, because so many new graphics had to be loaded to show the Pokedex that the tileset has to get entirely reloaded to return to the overworld.

Viewing your party and exiting does cause this graphical bug because there are few enough graphics that get loaded that the tileset didn't have to get overwritten at all (originally). Now that the hp bar does overlap with the tileset, just reload the tileset when exiting the party, the same way the Pokedex reloads the tileset when exiting, by calling ReloadMapData towards the beginning of StartMenu_Pokemon in engine/menu/start_sub_menus.asm

.exitMenu
    call GBPalWhiteOutWithDelay3
    call RestoreScreenTilesAndReloadTilePatterns
    call LoadGBPal
    call ReloadMapData
    jp RedisplayStartMenu
.chosePokemon

However, that is the only bug I can recreate, even with the +25 modification. What do you mean bugs with the intro and with talking to npcs?


Wild wrote:

EDIT: Curiously, when opening and closing the Trainer menu, this reloads and fixes the glitched graphics...

For the same reason that the Pokedex doesn't cause the bug, the trainer card forces a reload of the whole current tileset by calling ReloadMapData.


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#6 2016-12-31 03:23:22

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,011/1,021

Re: [Pokered] Expanding Tilesets

I just had another thought. Tile $00 in every tileset is a completely blank tile. You could use tile $00 for a new tile graphic, and then replace all $00's in the block data with $7f (which is always also a blank tile). Pretty sure no harm could be done by doing that.


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#7 2016-12-31 04:09:05

Wild
New member
From: The Land Down Under
Registered: 2016-12-30
Post 3/9

Re: [Pokered] Expanding Tilesets

I was just about to comment back saying calling ReloadMapData when exiting the Pokemon menu sorts it out, but you beat me to it, thanks :D

I will note that it appears to works better calling ReloadMapData before RestoreScreenTilesAndReloadTilePatterns
as it gives the game a fraction longer to reload the tileset. Calling it right before redisplaying the start menu results in a brief glitch being displayed on the tiles before they are reloaded.

.exitMenu
    call GBPalWhiteOutWithDelay3
    call ReloadMapData
    call RestoreScreenTilesAndReloadTilePatterns
    call LoadGBPal
    jp RedisplayStartMenu
.chosePokemon

With regard to the other graphical glitches that you weren't able to recreate, I have just realised that this is probably because I used the code to allow for 25 more tiles, but only included a tileset with a 128x56 pixel image, and 12 new tiles. Hence why amending your code to my specific needs fixed the problem.

Good suggestion also on using tile $00. Squeezing every byte out is the name of the game here!

Thanks for your help once again.

Offline

#8 2016-12-31 04:57:55

Rangi
Member
Registered: 2016-05-09
Post 439/554

Re: [Pokered] Expanding Tilesets

It looks like much the same technique would work for pokecrystal!

AnrqmpZ.pngp

home/map.asm:LoadTileset is responsible for loading the tileset graphics. The last two rows in VTiles2 (right) are, as far as I can tell, completely free. The last two rows in VTiles1 (left) get used for the textbox border, the location sign popup, and a few other things like the phone icon when calls happen. Plus they get overwritten by the trainer card, Pokédex, Pokégear, and HP+exp bars in the party menu. Still, around 40 more tiles should be available!

Edit:

It's fairly straightforward to use the last two rows in VTiles2: make sure that the tileset graphics are 128x112, and in home/map.asm:LoadTileset, change the $60 to $80 here:

ld hl, w6_d600
ld de, VTiles2
ld bc, $80 tiles
call CopyBytes

Also add more "tilepal" rows to the tileset/*_palette_map.asm files.

Now the metatiles should be able to use tile IDs $e0 to $ff!

N1fptGP.png

Last edited by Rangi (2016-12-31 05:22:37)


ROM hack: Pokémon Polished Crystal — version 2.2.0 released!

Offline

Board footer

Powered by FluxBB