PDA

View Full Version : Porting RS Tile System to Firered


NintendoBoyDX
December 30th, 2011, 03:41 PM
Hey everyone, as you may know there are differences between FRLG and RS with the major/minor tilesets. If not here is some info.

tile - a 8x8 pixel piece used to form blocks, there are 1024 tiles in 2 combined (major+minor) tilesets
block - has 2 layers, a top and bottom, each 16x16 pixels, each layer is made of 4 tiles, there are 1024 tiles in a major/minor tileset as well

RS:
Major tileset: DIB image size is 128x256 pixels
Minor tileset: DIB image size is 128x256 pixels
Major tileset: block amount is 512
Minor tileset: block amount is anywhere from 1-512
Major tileset: 512 tiles
Minor tileset: 512 tiles

As you can see the minor and majors are the same size in RS. But in FRLG, because gamefreak wanted to imitate RBY, they switched it up a bit.

FRLG:
Major tileset: DIB image size is 128x320 pixels
Minor tileset: DIB image size is 128x192 pixels
Major tileset: block amount is 640
Minor tileset: block amount is anywhere from 1-384
Major tileset: 640 tiles
Minor tileset: 640 tiles

Because I want to use RS's system on Fr I started a "port", but run into some problems. Here's what to do:

To insert the tilesets correctly make 2 small changes to advancemap.ini. Where it says Tilesethoehe*(tileset height), change it from 40 to 32.
And at Teil1Bloecke (amount of blocks in tileset 1) change it from $280 to $200(in decimal that is from 640 to 512). This way the tilesets now insert correctly, and you can have the correct block amounts, 512 and 512.

*Tilesethoehe is the major tileset's amount of vertical tiles. Since one tile is 8 pixels tall you could fit 32 in one column that is 256 pixels in length, and 40 in one that is 320 pixels in length. The width is not changeable it is always 128 pixels, aka 16 tiles. So obviously, there in a frlg major set there are 40*16 = 640 tiles, minor 24*16 = 384, for a total of 1024. And for rs both major and minor have 32*16 = 512 tiles. DO NOT let this fool you - there are 1024 tiles in 2 sets, and 1024 blocks made out of those tiles in 2 sets as well.

Now the remaining problems are with the code. They don't load correctly into VRAM. The thread below by ZDG shows how to do it in FR. Where it creates the 0x280 that later becomes 0x5000 and is added to vram to create the location for tileset 2, I changed it to 0x200 so that it becomes 0x4000 (the offset added to vram start address 0x06000000).
http://www.pokecommunity.com/showthread.php?t=203040
The other routines each of 0x280(640) and 0x180(384) and so I assume them to be the block amounts. I changed them all to 0x200(512). I even took a look at the changes in prime's DNS which alters the tile loading functions, and i've seemingly found them all (there are many spots around the area that use 0x280/27F and 0x180/17F.

My problem now is that the blocks are scrambled. The tilesets inserted correctly and load properly in vram, the blocks are formed correctly, but the problem is the block numbers are all messed up. For example, where I choose block 0x4, block 0x80 would show up. As far as I can tell it is always the same pattern of random blocks that show up - this happens on only the minor tileset, the major is fine.

I tried editing all these places which are part of the map routines:
08059090 area, 08059a50 area, 0805a970 area, 08070040 area, and 08070490 area. All I did was change the creation of the values 0x27F/17F/280/180 to 0x1FF/200, but still am getting that problem with the blocks. Obviously, I'm missing something or going about this the wrong way. Any ideas?

NintendoBoyDX
January 1st, 2012, 02:14 AM
Just sorted it out, changes needed are as follows:
change 080590D4 to 0xFFFFF800
change 0805A9B0 to 0xFFFFFE00
change 080590A4, 0809B808, and 0805A97C to 0x1FF
change 08059A56, 08059A70, 08059A84, 08059ABA, 0807015C, 08059A6C, 08059A80, and 08059AC8 to 0x200.
Change your amap settings for firered to 40 for tilesetheight and $200 for the block amount for tileset 1. You should be able to insert correctly and the game should load both tilesets correctly.

Needs more testing though...might be missing some stuff. Oh, and thanks Darthatron for pointing out that 0xFFFFE00 is also -0x280. :p

Darthatron
January 1st, 2012, 04:07 AM
Really nice work man. I knew you could pull it off. :)

Full Metal
January 1st, 2012, 09:37 AM
This is a very original idea, in my opinion.
But...I don't understand why you would want to do it.
FR offers more room for more blocks and tiles, does it not? :\
I would have swapped things the other way around.
Maybe there's just something I'm not seeing here...

NintendoBoyDX
January 1st, 2012, 11:36 AM
I did it simply because the tilesets I had make more sense this way. And actually, you get many more tiles out of it. You have 2 majors in both, but many more minors in each. The majors may be a bit smaller in ruby but the minors are much bigger.
i.e. if you have 64 sets...
Fr: 2 ma: 640 * 2 = 1280
62 mi: 384 * 62 =23038
total = 25088
RS: 2 maj: 512 * 2 = 1024
62 min: 512 * 62 = 31744
total = 32768
That goes for blocks and tiles. So much more space, and thats only setting the major to the same size :P

The other thing is now its completely customizable. You could for example use next to no space for the major sets and that gives you a lot more space in the minors. Just edit the amap.ini and the code values to what you nee.

Full Metal
January 1st, 2012, 04:09 PM
Ahh, I see. That is actually a pretty good advantage there!

Chaos Rush
May 31st, 2012, 01:56 PM
change 08059A56, 08059A70, 08059A84, 08059ABA, 0807015C, 08059A6C, 08059A80, and 08059AC8 to 0x200.
Are you sure those offsets are correct? None of those offsets are originally 0x180 or 0x280 (reading your logic in the first post), and when I tried the whole process (yes, I edited the AMap ini, and yes, I imported tile and palette data for both tilesets from Pokemon Ruby), but all I ended up with is a black screen.

Are you working with a different-language ROM?

NintendoBoyDX
June 1st, 2012, 02:50 PM
Are you sure those offsets are correct? None of those offsets are originally 0x180 or 0x280 (reading your logic in the first post), and when I tried the whole process (yes, I edited the AMap ini, and yes, I imported tile and palette data for both tilesets from Pokemon Ruby), but all I ended up with is a black screen.

Are you working with a different-language ROM?

Sorry man, should have specified this. Assuming you want the RS tileset system exactly... well, let's take a look at this (fr US):

1. change 080590D4 to 0xFFFFF800
2. change 0805A9B0 to 0xFFFFFE00
3. change 080590A4, 0809B808, and 0805A97C to 0x1FF
4. change 08059A56, 08059A70, 08059A84, 08059ABA, 0807015C, 08059A6C, 08059A80, and 08059AC8 to 0x200.

1. 080590D4 is word that is loaded. Originally, this is 0xFFFFF600. Take 0x280 and shift it left twice and subtract that from 0x100000000, is the easiest way to figure it out. It works in reverse. We want 0x200 left shifted twice, so simply change it to 0xFFFFF800.

2. 0805A9B0 is also a loaded word. Originally it is 0xFFFFFD80, which is 0x100000000 minus 0x280. We need 0x200, so change it to 0xFFFFFE00.

3. 080590A4, 0809B808, and 0805A97C are all loaded halfwords, and are all 0x27F by default. (0x280 - 1). We're again aiming for 0x200, so change these 3 to 0x1FF.

4. These last 8 locations are sections of code. (By default all of these are 0x280 or 0x180, And we need want 0x200 to use the RS tileset system). They use a trick that save memory, and is much faster than loading to create the values. It uses a mov command to generate a certain value, then just bitshifts it left. So again, these are asm code areas, not data. Easiest way to do this is to copy 0x80 into the register then shift it left twice. I can provide a patch if you like.

In other words for 4 just do this:
In hex:
Change 08059A58 to 80
Change 08059A6C to 80 and 08059A6E to 89
Change 08059A70 to 80
Change 08059A80 to 80 and 08059A82 to 89
Change 08059A84 to 80
Change 08059ABA to 80
Change 08059AC8 to 80 and 08059ACA to 89
Change 0807015C to 80

Should take care of it

RaileysXerilyasRX
June 11th, 2014, 07:16 PM
Nice! :D But what about for Doors. :)

Tao Dragon
July 2nd, 2014, 10:32 AM
Hey everyone, as you may know there are differences between FRLG and RS with the major/minor tilesets. If not here is some info.

tile - a 8x8 pixel piece used to form blocks, there are 1024 tiles in 2 combined (major+minor) tilesets
block - has 2 layers, a top and bottom, each 16x16 pixels, each layer is made of 4 tiles, there are 1024 tiles in a major/minor tileset as well

RS:
Major tileset: DIB image size is 128x256 pixels
Minor tileset: DIB image size is 128x256 pixels
Major tileset: block amount is 512
Minor tileset: block amount is anywhere from 1-512
Major tileset: 512 tiles
Minor tileset: 512 tiles

As you can see the minor and majors are the same size in RS. But in FRLG, because gamefreak wanted to imitate RBY, they switched it up a bit.

FRLG:
Major tileset: DIB image size is 128x320 pixels
Minor tileset: DIB image size is 128x192 pixels
Major tileset: block amount is 640
Minor tileset: block amount is anywhere from 1-384
Major tileset: 640 tiles
Minor tileset: 640 tiles

Because I want to use RS's system on Fr I started a "port", but run into some problems. Here's what to do:

To insert the tilesets correctly make 2 small changes to advancemap.ini. Where it says Tilesethoehe*(tileset height), change it from 40 to 32.
And at Teil1Bloecke (amount of blocks in tileset 1) change it from $280 to $200(in decimal that is from 640 to 512). This way the tilesets now insert correctly, and you can have the correct block amounts, 512 and 512.

*Tilesethoehe is the major tileset's amount of vertical tiles. Since one tile is 8 pixels tall you could fit 32 in one column that is 256 pixels in length, and 40 in one that is 320 pixels in length. The width is not changeable it is always 128 pixels, aka 16 tiles. So obviously, there in a frlg major set there are 40*16 = 640 tiles, minor 24*16 = 384, for a total of 1024. And for rs both major and minor have 32*16 = 512 tiles. DO NOT let this fool you - there are 1024 tiles in 2 sets, and 1024 blocks made out of those tiles in 2 sets as well.

Now the remaining problems are with the code. They don't load correctly into VRAM. The thread below by ZDG shows how to do it in FR. Where it creates the 0x280 that later becomes 0x5000 and is added to vram to create the location for tileset 2, I changed it to 0x200 so that it becomes 0x4000 (the offset added to vram start address 0x06000000).
http://www.pokecommunity.com/showthread.php?t=203040
The other routines each of 0x280(640) and 0x180(384) and so I assume them to be the block amounts. I changed them all to 0x200(512). I even took a look at the changes in prime's DNS which alters the tile loading functions, and i've seemingly found them all (there are many spots around the area that use 0x280/27F and 0x180/17F.

My problem now is that the blocks are scrambled. The tilesets inserted correctly and load properly in vram, the blocks are formed correctly, but the problem is the block numbers are all messed up. For example, where I choose block 0x4, block 0x80 would show up. As far as I can tell it is always the same pattern of random blocks that show up - this happens on only the minor tileset, the major is fine.

I tried editing all these places which are part of the map routines:
08059090 area, 08059a50 area, 0805a970 area, 08070040 area, and 08070490 area. All I did was change the creation of the values 0x27F/17F/280/180 to 0x1FF/200, but still am getting that problem with the blocks. Obviously, I'm missing something or going about this the wrong way. Any ideas?

Hey, um, I want to import firered tilesets to emerald rather than r/s tilesets to firered. And also I have no idea where the info given applies. You talk about editting the ini in advance map but all I see are some numbers like 80 and the likes and words written in german. I assume I have to edit the ini in conjunction with hex editor right? If this is the case then I'll have to start using it. I suppose it's possible to do the inverse from fr to r/s. The thing is I don't know if emerald is exactly the same as r/s. And I also need to know where I'm going to apply this information.

What I've been doing is recoloring firered tilesets in ms paint which works but it takes time. Your way seems to be more direct. I also have another problem there is a limit of tiles I can import and the ones at the bottom don't display. Is there a way to increase the number of tiles I can import to tileset 0?