Having trouble with rainwarrior's ca65 template

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
battagline
Posts: 152
Joined: Wed Sep 05, 2018 11:13 am
Location: Colorado
Contact:

Having trouble with rainwarrior's ca65 template

Post by battagline »

So I've been playing around with rainwarrior's ca65 template, and when I change out the background tiles, the sprites disappear from the PPU Viewer in FCEUX, and no cursor shows up. If I swap out the sprite file I don't have the same issue. I'm not sure what's going on here, I've tried sizing it the same but that doesn't seem to matter. What kind of magic is going on in that .chr file that I'm not aware of?

I'm using photoshop to make my sprites and I'm using yy-chr to export the new .chr files.

Any suggestions?

Thanks
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Having trouble with rainwarrior's ca65 template

Post by rainwarrior »

Well, I suspect a similar problem as in your other post. Most likely this sounds like your CHR file is too small. What is its size?

You can divide the CHR up into separate files however you like, and incbin them all in the TILES segment. The first 4kb goes to background, the second 4kb goes to sprites. How you put that together is up to you, but if you don't fill up that first 4kb you won't be putting anything in the second 4kb where sprites go.
User avatar
battagline
Posts: 152
Joined: Wed Sep 05, 2018 11:13 am
Location: Colorado
Contact:

Re: Having trouble with rainwarrior's ca65 template

Post by battagline »

rainwarrior wrote:Well, I suspect a similar problem as in your other post. Most likely this sounds like your CHR file is too small. What is its size?

You can divide the CHR up into separate files however you like, and incbin them all in the TILES segment. The first 4kb goes to background, the second 4kb goes to sprites. How you put that together is up to you, but if you don't fill up that first 4kb you won't be putting anything in the second 4kb where sprites go.
Thanks for the help. So do I need to size the .chr file to exactly 4K? It looks like they are saving out at 8K, but there really isn't much there. Maybe I'm not using yy-chr right? Does yy-chr have some way to configure it to export a 4K file. It looks like yy-chr has enough space for 16x16 sprites. Is it expecting me to put both the background tiles and the sprites into the same file?

Thanks again for your help
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Having trouble with rainwarrior's ca65 template

Post by rainwarrior »

You could put them both together in an 8k file if you want.

I can't tell you how to use YY-CHR, but 256 8x8 tiles is 4kb of CHR. (256 = 16x16, and I assuming you were counting sprite tiles as 16 per row?) Each tile is 16 bytes of CHR data. (2 bits per pixel / bpp)
User avatar
battagline
Posts: 152
Joined: Wed Sep 05, 2018 11:13 am
Location: Colorado
Contact:

Re: Having trouble with rainwarrior's ca65 template

Post by battagline »

rainwarrior wrote:You could put them both together in an 8k file if you want.

I can't tell you how to use YY-CHR, but 256 8x8 tiles is 4kb of CHR. (256 = 16x16, and I assuming you were counting sprite tiles as 16 per row?) Each tile is 16 bytes of CHR data. (2 bits per pixel / bpp)

All right! So it looks like yy-chr makes a single 8K file with both tile & sprite data in it. The top half is the tile data and the bottom is the sprite data.

What do most people use? I had seen yy-chr thrown around in the forums and elsewhere as a tool for creating the .chr files. I'm not particularly fond of yy-chr, but I have no idea what my other options are.

Thanks again!
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
User avatar
samophlange
Posts: 50
Joined: Sun Apr 08, 2018 11:45 pm
Location: Southern California

Re: Having trouble with rainwarrior's ca65 template

Post by samophlange »

battagline wrote:
All right! So it looks like yy-chr makes a single 8K file with both tile & sprite data in it. The top half is the tile data and the bottom is the sprite data.

What do most people use? I had seen yy-chr thrown around in the forums and elsewhere as a tool for creating the .chr files. I'm not particularly fond of yy-chr, but I have no idea what my other options are.

Thanks again!
I found Shiru's NES Screen Tool to be easier to use than yy-chr, and it has options to work with CHR data in 4k or 8k pieces
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Having trouble with rainwarrior's ca65 template

Post by dougeff »

single 8K file with both tile & sprite data in it. The top half is the tile data and the bottom is the sprite data.
The PPU loads 2 tilesets. #0 and #1.

Background can use either 0 or 1. Sprites can use 0 or 1. They can both use the same tileset, if you like. Background can use tileset 0 for the top half of the screen and 1 for the bottom half of the screen (by changing it halfway).

PPU control register does this, with these bits

xxxB Sxxx

Where B is the bit for BG tileset, S is the bit for Sprite tileset.

For most nes games, it doesn't matter which you choose, but apparently, for mapper MMC3, is matters. The wiki says "The standard configuration is to use PPU $0000-$0FFF for background tiles and $1000-$1FFF for sprite tiles", so I suppose you are correct...ish.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Having trouble with rainwarrior's ca65 template

Post by Banshaku »

dougeff wrote:For most nes games, it doesn't matter which you choose, but apparently, for mapper MMC3, is matters. The wiki says "The standard configuration is to use PPU $0000-$0FFF for background tiles and $1000-$1FFF for sprite tiles", so I suppose you are correct...ish.
I would love to know more about that possible "quirk". After reading that message, halfway I thought "oh! why I didn't think about putting the fonts into the sprite bank so I can just switch to bg in sprite, idiot!" (I was going to switch one bank inside BG one for that) but you mention and mmc3 issue. oupsie :lol:

Maybe another thread would be more appropriate? I'm curious about it since it would impact how I continue for code inside intro/cutscene which often doesn't require much sprites.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Having trouble with rainwarrior's ca65 template

Post by calima »

It only affects IRQs. So if you switch in your last IRQ, it won't cause any trouble.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Having trouble with rainwarrior's ca65 template

Post by Banshaku »

I see. Now I just need to first make my first IRQ behave properly before switching bg<->sprite banks :lol: Thank you for the information!
Post Reply