copying RAM->VRAM tilemap

Page 2/2
1 |

Par norakomi

Paragon (1133)

Portrait de norakomi

30-10-2021, 11:36

ARTRAG wrote:

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

So I would copy the first 8 lines of tile 1, then the first 8 lines of tile 2 and repeat until the last tile (32).
Then repeat the whole process starting at the 2nd line....
Didn't think about that. That would save time indeed !! I will try that.


Enlighted (6891)

Portrait de ARTRAG

30-10-2021, 15:15

If you keep the addresses of the tiles in ram (16 words) you can reuse them for the next pixel lines
In this case you will skip other computations till the next line of tiles


Enlighted (6891)

Portrait de ARTRAG

30-10-2021, 19:19

It could look like something like this (in pseudo code)

j = address of you screen map in ram (16x12 bytes)

set vram pointer to 0

for yy=0 to 12  ' loop on rows in the screen map

' compute the addresses of data of the first line of data
for xx=0 to 15
 ramaddr(xx) = address of pixels of tile (j)
 j = j+1

' plot all tiles in the image 16x12
for y=0 to 15 ' loop in the number of lines of a tile
' plot a line of pixels of the screen (256 pixels)
for i=0 to 15 ' loop on the number of tiles in a raw
  ' plot a line in a tile
   hl = ramaddr(i)
   ramaddr(i) = hl


Par Grauw

Ascended (10639)

Portrait de Grauw

30-10-2021, 19:43

Something that can be useful for optimisation; if the tile data is aligned in memory, so their address is aligned to either 128 bytes (screen 5) or 256 bytes (screen 8), the lower 7 bits or 8 bits can be determined from the X / Y position. (Assuming 16x16 tiles here.)

In the case of screen 5, if you don’t want to deal with masking that 8th bit in and out of the LSB, just be wasteful and pad the tile data to make it align to 256 bytes anyway. To be less wasteful, find some useful data to place in that padding, for example could have tile data there that’s pre-rotated for faster vertical output.

Page 2/2
1 |