copying RAM->VRAM tilemap

Página 1/2
| 2

Por norakomi

Paragon (1150)

imagem de norakomi

27-10-2021, 08:12

Hi all !!

I have a tilemap 256x256 in screen 5 which I first copy to Vram Page 3 using Outi instructions. This is 32kb in total.
The tiles are in 8x8 format.
I then use these tiles to build up the screen in Page 0 using a HMMM copy instruction per tile.

I basically copy all the tiles to Page 3 first with Outi instructions and then build up the screen with HMMM copy instructions.

This is pretty slow and I'm wondering if there is a way to do this faster.

Could I directly build up the screen in Page 0 leaving the tilemap in Ram ?
I preferably want to do this without Vram copy instructions, using only the CPU.

What would be the best way to do this ?

Entrar ou registrar-se para comentar

Por ARTRAG

Enlighted (6977)

imagem de ARTRAG

27-10-2021, 09:33

If speed is your sole concern, the fastest way to update the video is when CPU and VDP engine work in parallel. This implies that the tiles have to stay both in VRAM and in ROM/Ram. While the vdp is busy copying tiles vam to vram, you can outi data to vram using the CPU and port 98h. With a bit of fine tuning you can interleave the correct number of outi in oder to end exactly when the vdp has ended its copy task avoiding the testing of the CE bit. Naturally timing changes if you admit r800 and accelerated z80s

Por erpirao

Paragon (1334)

imagem de erpirao

27-10-2021, 20:52

I think that in "brain drive" they do some of that in the TurboR, I remember that each character is 96KB of .sr5

download linlk: brain drive

Por geijoenr

Champion (391)

imagem de geijoenr

27-10-2021, 21:23

I would recommend to look at this:

http://map.grauw.nl/articles/vdp_commands_speed.php

I think the best approach is to use macro-tiles to define the map (blocks made of several tiles) instead of small 8x8 tiles as you would do in screen 4.

Some MSX2 games use this approach and is fast enough to switch rooms in screen 5 (I think Metal Gear is an example).

Por Grauw

Ascended (10821)

imagem de Grauw

27-10-2021, 21:59

HMMM or HMMC are roughly the same speed.

Using 16x16 tiles instead of 8x8 tiles is better for speed.

I think Akin and Core Dump are one of the most impressive examples of screen 5 8x8 tile based games. Back in the 90s Cas Cremers wrote some details on what he did in Core Dump on his blog (before the term blog was invented). Feel free to also read some of his other entries. I believe he also used HMMV for single-colour tiles but I can’t find any reference to that now.

Por norakomi

Paragon (1150)

imagem de norakomi

28-10-2021, 08:49

Quote:

HMMM or HMMC are roughly the same speed.

HMMC does ocupy the VDP, right ? I can't use them in unison ?
What is the fastest way to copy 1 tile from Ram to Vram?
Let's say I use 16x16 tiles. The tilesheet is 256x256 and looks like this:
I have this tilesheet in Ram, at address $8000 for instance.
If I want to copy the first tile to any Vram address...
I would have to copy the first 16 pixels, then increase RAM address by 1 line, do the same for VRAM and repeat until all 16 lines are copied.
Would it be better to have this tile spread out horizontally like so:
Then you can copy the first 16 pixels, then you dont need to change RAM address, only VRAM (going to the next line) and repeat until all 16 lines are copied.
Any thoughts on this ?

Por ARTRAG

Enlighted (6977)

imagem de ARTRAG

28-10-2021, 08:46

Why don't you change the ram address to the next tile?
You can precompute the 16 addresses in a ram array and use them for the first line of tiles

Por snake

Expert (71)

imagem de snake

28-10-2021, 20:08

Copying tiles from a page to another in order to build static screen stages (for instance: Metal Gear) is reasonably fast with HMMM. I got very good results even in screen 8 with 16x16 tiles.

But if you plan to do that every frame (for instance: scrolling, software sprites), please, note that copy speed is about 1-4 kb per interrupt, so you likely have to redesign your gfx engine.

Por max_iwamoto

Paladin (673)

imagem de max_iwamoto

28-10-2021, 20:40

I believe the good way to increase speed is to check if current tile is the same as previous screen and skip copying it altogether. Fray and other Microcabin games using this technique.

Por ARTRAG

Enlighted (6977)

imagem de ARTRAG

29-10-2021, 09:52

max_iwamoto wrote:

I believe the good way to increase speed is to check if current tile is the same as previous screen and skip copying it altogether. Fray and other Microcabin games using this technique.

Sure, the fastest copy is the one you don't do.
Also dealing with uniform tiles separately helps, when you use the vdp commands

Only I see that the problem posed is a bit vague, because we do not know if we deal with a page flipping game or with a scrolling and why do not exploit the vdp command engine

Por Arjan

Paladin (787)

imagem de Arjan

29-10-2021, 13:40

If the game is using software sprites it needs at least one copy of the screen if you want to avoid flickering (one page to display, one page to build the next frame) and maybe even another copy to be able to quickly erase software sprites.

ARTRAG's approach of precalculating the tile addresses for each row and outputting the tiles line by line is pretty good. Creating duplicates using YMMM can be done almost for free.

Página 1/2
| 2