Hi,
I'm using cc65 but I can add assembly code.
I have to display a image (without animation) for the title of a game but I have almost 512 tiles. I know I can use 8x16 sprites but with the limitation of 8 sprite per line.
Can we extend the chr bank to have more tiles? Or maybe draw pixel by pixel in vram ($2000 -> $2400) instead of tiles as the picture will not be animated ?
fix screen 512 tiles
Moderator: Moderators
Re: fix screen 512 tiles
You can use more than 256 tiles in one screen if you switch to the other pattern table mid-screen. For example you can use tiles from the first pattern table on scanlines 0 through 119, then trigger a sprite 0 hit on that scanline and tell the PPU to start using tiles from the second pattern table (i.e. use bit 4 of PPUCTRL), causing scanlines 120 through 239 to use another set of tiles. Then, during vblank, you write to PPUCTRL again to revert to the first pattern table for the start of the next frame.
Re: fix screen 512 tiles
I tried like you say : I draw first part of the screen with first pattern and the second pattern but this doesn't work
But I can make it inside my NMI with testing sprite hit from Nesdoug tutorial
Sprite Hit :
Code: Select all
PPU_ADDRESS = 0x20;
PPU_ADDRESS = 0x40;
for( index = 0; index < 416; ++index ){
PPU_DATA = tilehaut[index];
}
PPU_CTRL = 0x10; %0001 0000
PPU_CTRL = 0x10;
PPU_ADDRESS = 0x21;
PPU_ADDRESS = 0xE0;
for( index = 0; index < 448; ++index ){
PPU_DATA = tilebas[index];
}
Code: Select all
PPU_CTRL = 0x90;
Sprite_Hit();
PPU_CTRL = 0x80;
Code: Select all
_Sprite_Hit:
Sprite0:
lda $2002
and #$40
bne Sprite0
Sprite0b:
lda $2002
and #$40
beq Sprite0b
rts
My work :
https://twitter.com/budgames
https://twitter.com/budgames
Re: fix screen 512 tiles
No, that's not how it works.
The status of the pattern table select bit in $2000 affects the rendering - that is what pattern table is shown when the PPU is rendering the frame. It's status has no effect when writing to $2007.
What tokumaru proposed is to split the screen in 2 regions, using a raster split technique. You want the $2000.4 bit to be '1' for one part of the screen and '0' for the other part, so you need to change this 2 times per frame. Perhaps the FAQ I wrote about the subject will be helpful. Especially the "Synchronizing with the PPU" chapter.
The status of the pattern table select bit in $2000 affects the rendering - that is what pattern table is shown when the PPU is rendering the frame. It's status has no effect when writing to $2007.
What tokumaru proposed is to split the screen in 2 regions, using a raster split technique. You want the $2000.4 bit to be '1' for one part of the screen and '0' for the other part, so you need to change this 2 times per frame. Perhaps the FAQ I wrote about the subject will be helpful. Especially the "Synchronizing with the PPU" chapter.
Re: fix screen 512 tiles
Yeah, the pattern table selection affects what's displayed on the screen, it doesn't affect what the name tables can hold, which is always values between 0 and 255. Every frame, the PPU reads tile indices from the name tables and then fetches the corresponding patterns for displaying, so you can point to another pattern table mid-frame, causing the PPU to fetch different patterns for the same 256 indices, effectively giving you 512 tiles in a single screen.
For example, let's say that tile 0 of the first pattern table contains a circle, and tile 0 of the second pattern table contains a triangle. During vblank, you set the background to use the first PT, so every time the PPU finds the number 0 in the NT, it will draw a circle. Then comes the sprite 0 hit, and you tell the PPU to use tiles from the second PT for the background. From that point on, every time the PPU finds a 0 in the NT, it'll draw a triangle.
You have to keep switching the pattern tables like this every frame, because the PPU fetches everything for rendering every frame. Select the first PT for the background during vblank, then switch to the second PT after the sprite 0 hit.
For example, let's say that tile 0 of the first pattern table contains a circle, and tile 0 of the second pattern table contains a triangle. During vblank, you set the background to use the first PT, so every time the PPU finds the number 0 in the NT, it will draw a circle. Then comes the sprite 0 hit, and you tell the PPU to use tiles from the second PT for the background. From that point on, every time the PPU finds a 0 in the NT, it'll draw a triangle.
You have to keep switching the pattern tables like this every frame, because the PPU fetches everything for rendering every frame. Select the first PT for the background during vblank, then switch to the second PT after the sprite 0 hit.
Re: fix screen 512 tiles
Thanks, I think I get it now.
It's working well on emulator, need to test on real hardware now.
It's working well on emulator, need to test on real hardware now.
My work :
https://twitter.com/budgames
https://twitter.com/budgames
Re: fix screen 512 tiles
Yes, you can have bankable CHR to have more than 512 tiles. You would generally have to change what banks are mapped in with raster timing, similarly to what others posted here.tonma wrote: Can we extend the chr bank to have more tiles?