Spreite 8x8 to 8x16

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
tonma
Posts: 23
Joined: Tue Mar 28, 2017 6:26 am
Contact:

Spreite 8x8 to 8x16

Post by tonma » Wed Mar 29, 2017 8:03 am

hi,
I'm a beginner on Nes and using cc65.
I can display sprites, background, move sprites, palettes, attributes ... and even change bank for graphics / chr.

I read the articles on nesdev wiki but I have a worry when I want to display sprites in 8x16.
My code works in 8x8 and with metatiles.
I change the size of the sprites by changing the PPUCTRL to 0x2000 From 0x90 (1001 000) to 0xB0 (1011 000).
00X0 0000 : X = 0 -> 8x8
: X = 1 -> 8x16

I must do it wrong. Do I need to change something in my code.
I write the values of my sprites in OAM in 0x200 (Y,Tile Num, Attrib, X, ...);
As you can see in pictures, the NES only draw the top of my sprites (8x8)

Code: Select all

SPRITES[0] = 16; // Y
		SPRITES[1] = 0; // Tile num
		SPRITES[2] = 0; // Atributes
		SPRITES[3] = 24; // X
		
		
		SPRITES[4] = 16;
		SPRITES[5] = 0x10;
		SPRITES[6] = 0;
		SPRITES[7] = 48;
Image

User avatar
Bregalad
Posts: 7889
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Spreite 8x8 to 8x16

Post by Bregalad » Wed Mar 29, 2017 8:07 am

That's because the way pattern tables are displayed by most debuggers aren't 8x16-sprites-friendly. It displays tile $10 below tile $00, but when set in 8x16 sprite mode, the NES will display tile $01 below tile $00.

Some CHR editors such as YY-CHR or Tile-Molester have an enablable option to display tiles in a layout that is 8x16-sprites-friendly, I don't know whether any emulator with debug and VRAM viewer has this option as well.

User avatar
dougeff
Posts: 2710
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Spreite 8x8 to 8x16

Post by dougeff » Wed Mar 29, 2017 8:09 am

It's sequential.

In 8x16 mode, you tell it to use tile #1. The sprite will be composed of tile #1 (top) and tile #2 (bottom).

Not tile #1 and tile #$11, as you have.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
rainwarrior
Posts: 7824
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Spreite 8x8 to 8x16

Post by rainwarrior » Wed Mar 29, 2017 8:10 am

How are your changing the value written to $2000? Whatever library you're using probably writes it during vblank, so you need to tell the library to do that using whatever interface it might have for doing so.

If you open FCEUX's debugger and put a breakpoint on writes to $2000 you can see exactly what and when is getting written to it.

Can you post a ROM?
Bregalad wrote:That's because the way pattern tables are displayed by most debuggers aren't 8x16-sprites-friendly. It displays tile $10 below tile $00, but when set in 8x16 sprite mode, the NES will display tile $01 below tile $00.

Some CHR editors such as YY-CHR or Tile-Molester have an enablable option to display tiles in a layout that is 8x16-sprites-friendly, I don't know whether any emulator with debug and VRAM viewer has this option as well.
This shouldn't be the problem. FCEUX has an 8x16 tile display mode, and OP has it enabled. You can see the checkbox in the screenshot they posted.

tonma
Posts: 23
Joined: Tue Mar 28, 2017 6:26 am
Contact:

Re: Spreite 8x8 to 8x16

Post by tonma » Wed Mar 29, 2017 8:51 am

Thanks you all.

It was because of the value of $2000. I checked with the debugger as you ask me and the value was the same as the older.
I change the value when my screen is off at start. But I had also placed it in my NMI function in asm. Remove from it and it's working.

I could not remember the change. 3 hours for that. :mrgreen:

But it's working now. Need to replace my tile in my chr file but it's ok. I walked step by step.

User avatar
Bregalad
Posts: 7889
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Spreite 8x8 to 8x16

Post by Bregalad » Wed Mar 29, 2017 10:45 am

rainwarrior wrote: This shouldn't be the problem. FCEUX has an 8x16 tile display mode, and OP has it enabled. You can see the checkbox in the screenshot they posted.
Ooops, my bad. I didn't even know about this feature, it's a nice thing to have !

If I'm not mistaken the SNES actually handles sprites larger than 8x8 in a way that is more friendly to tile viewer (but less friendly to hardware), for example a 16x16 sprite with index $00 would be made of 8x8 sprites $00, $01, $10 and $11.

tonma
Posts: 23
Joined: Tue Mar 28, 2017 6:26 am
Contact:

Re: Spreite 8x8 to 8x16

Post by tonma » Fri Mar 31, 2017 12:44 am

No problem.

I use yy-chr and I can actually modify the bank of sprites in 8x16 but if you change the background bank after, it also changes the order of the tiles for the background in 8x16.
So I prefer to use the normal mode for bank sprites.

Post Reply