This tutorial answers how to slice and merge binary NES assets, using the cc65 suite.
So the example is kind of redundant for all you seasoned programmers since you can achieve the same result with one line in bash or PowerShell (probably).
I found it useful to make this little "ca65 script" to be able to quickly pick and merge strips of tile data into one chr-rom file.
In the example, it takes most rows of tiles from dummy0.chr and the 3 last rows of dummy1.chr and concatenate them into one 4kB binary. This was used to copy common tiles (an alphabet + some HUD symbols) across level tilesheets.
ca65 has a very versatile .incbin directive. it lets you set offset and length. This means you can grab a portion of any binary. This is pretty useful for tiles especially.
For me, it circumvened having to use yy-chr to do the job, and since you can't copypaste between several NESST instances (each has its own clipboard space for tile data), this was the quickest way for me. Now i've got the script for every time i need to bake a new level tileset specific to this project.
Baby steps to make the example work:
1) install cc65 suite somewhere if you haven't
2) You need to rename the path:s in the .bat file to fit your environment.
3) optional: in merger.s, replace dummy0.chr and dummy1.chr with the files you want to merge
4) run merger.bat
It will replace and produce a new tileset called merged.chr
For any practical use of the example files specific to your project, you can:
al) adjust the offsets and lengths to taste. Remember to multiply by 16 or $10 if you're counting tiles, rather than bytes
b) add in as many or as few .incbin directives as you need.
c) change the expected size of the output in the .cfg file by changing "size = $1000" (4kB:s) to something else.
d) replace my magic numbers with some defined constants that make sense to you.
Mostly, i'm just hoping this'll raise some awareness that you can use .incbin more flexibly in any project. It can for example nondestructively pick and choose subsets of assets everytime you build your program, or sometimes just simply circumvene the need for external tools or repeated command line tasks.
So the example is kind of redundant for all you seasoned programmers since you can achieve the same result with one line in bash or PowerShell (probably).
I found it useful to make this little "ca65 script" to be able to quickly pick and merge strips of tile data into one chr-rom file.
In the example, it takes most rows of tiles from dummy0.chr and the 3 last rows of dummy1.chr and concatenate them into one 4kB binary. This was used to copy common tiles (an alphabet + some HUD symbols) across level tilesheets.
ca65 has a very versatile .incbin directive. it lets you set offset and length. This means you can grab a portion of any binary. This is pretty useful for tiles especially.
For me, it circumvened having to use yy-chr to do the job, and since you can't copypaste between several NESST instances (each has its own clipboard space for tile data), this was the quickest way for me. Now i've got the script for every time i need to bake a new level tileset specific to this project.
Baby steps to make the example work:
1) install cc65 suite somewhere if you haven't
2) You need to rename the path:s in the .bat file to fit your environment.
3) optional: in merger.s, replace dummy0.chr and dummy1.chr with the files you want to merge
4) run merger.bat
It will replace and produce a new tileset called merged.chr
For any practical use of the example files specific to your project, you can:
al) adjust the offsets and lengths to taste. Remember to multiply by 16 or $10 if you're counting tiles, rather than bytes
b) add in as many or as few .incbin directives as you need.
c) change the expected size of the output in the .cfg file by changing "size = $1000" (4kB:s) to something else.
d) replace my magic numbers with some defined constants that make sense to you.
Mostly, i'm just hoping this'll raise some awareness that you can use .incbin more flexibly in any project. It can for example nondestructively pick and choose subsets of assets everytime you build your program, or sometimes just simply circumvene the need for external tools or repeated command line tasks.