# copying RAM->VRAM tilemap

Página 2/2
1 |
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

interesting...
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.

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

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
j = j+1
next

' 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
outi;outi;outi;outi;outi;outi;outi;outi
next
next

next
```

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.

Página 2/2
1 |