Fastest way to fill the visible part of a background layer?
Moderators: BigEvilCorporation, Mask of Destiny
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Fastest way to fill the visible part of a background layer?
Hi,
At the very first frame of my game, I fill out the visible tiles of the A plane. (when the screen scrolls around, I just fill out the edges that become visible) Currently this plane fill function, which I've only done a first pass on, is noticeably slow. I'm calling VDP_setTileMap for every tile and you can see the screen filling up. So my function is an obvious candidate for optimization. So what's a faster way of doing this?
My first thought was to use VDP_setTileMapRect but it assumes that the source data is no bigger than the plane. My demo level is 256 x 64 which is larger than the 64 x 64 A plane I've configured. And future levels will be bigger than that. I can always make a new version of the function to work for my case but I'm not sure if that's the fastest available method.
Would it be faster to do DMA transfers of the visible rows from the game's level background data to the plane? Are there any other techniques available?
Thanks,
DJCC
At the very first frame of my game, I fill out the visible tiles of the A plane. (when the screen scrolls around, I just fill out the edges that become visible) Currently this plane fill function, which I've only done a first pass on, is noticeably slow. I'm calling VDP_setTileMap for every tile and you can see the screen filling up. So my function is an obvious candidate for optimization. So what's a faster way of doing this?
My first thought was to use VDP_setTileMapRect but it assumes that the source data is no bigger than the plane. My demo level is 256 x 64 which is larger than the 64 x 64 A plane I've configured. And future levels will be bigger than that. I can always make a new version of the function to work for my case but I'm not sure if that's the fastest available method.
Would it be faster to do DMA transfers of the visible rows from the game's level background data to the plane? Are there any other techniques available?
Thanks,
DJCC
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
DMA is your friend, and auto increment is your other friend. I could update all needed in my pattern table update by just doing 2x VRAM transfers combined with right auto increment value.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Ah, I didn't know you could turn off the screen! I'll try that tonight.Shiru wrote:You supposed to turn the screen off while putting all needed data (graphics, initial nametable data) into the VRAM. When the screen is turned off, there is no need to fit into the vblank time, so you can fill up the VRAM much faster.
When turning off the screen, does it keep the last visible image? Or does it just go black or whatever the default background color is?
Does the DMA transfer use the auto increment in any way on its own?TmEE co.(TM) wrote:DMA is your friend, and auto increment is your other friend. I could update all needed in my pattern table update by just doing 2x VRAM transfers combined with right auto increment value.
DJCC
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Auto increment increases the VDP address pointer on any VRAM access, be it CRAM, VRAM, VSRAM, done by 68K or DMA. It only increments though, no decrement.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
I haven't had the chance to try this yet, but I was wondering about using DMA and auto-increment together.
Does auto-increment increment only after the completion of the DMA transfer or for every byte/word DMA does?
So, for a DMA transfer of 4 bytes to index 0 and an auto increment of 2 bytes, will it be:
DMA writes be to 0, 2, 4, 6 with auto increment pointer at 8?
or
DMA writes to 0,1,2,3 with auto increment pointer at 5?
Does auto-increment increment only after the completion of the DMA transfer or for every byte/word DMA does?
So, for a DMA transfer of 4 bytes to index 0 and an auto increment of 2 bytes, will it be:
DMA writes be to 0, 2, 4, 6 with auto increment pointer at 8?
or
DMA writes to 0,1,2,3 with auto increment pointer at 5?
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
It increments the address pointer by value in the register on every word/byte it transfers
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Does it apply the auto increment to the source location as well as the destination?TmEE co.(TM) wrote:It increments the address pointer by value in the register on every word/byte it transfers
If I DMA 4 bytes from address 0 to address 8, will reads be from source address be 0,1,2,3 or 0,2,4,6? (destination addresses, from your answer, will be 8,10,12,14)
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Only destination is affected
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am