Obrigado a Julio Marchi pelo espaço cedido na MSX All
Create animated displays for MSX screen 2 images.
Instead of loading the image right to the VRAM like the Basic command BLOAD does, the display program first loads the image on RAM memory, then it copies the data to the VRAM. This give us the control on how to transfer the image data to the screen, making it possible to introduce some animation effects while loading the image on screen.
Once screen 2 is composed by a pattern and color tables, this copy is performed in two steps. We may transfer 1x8 or 8x8 pixel blocks at time, but in this operation we must transfer the same pattern and color tables block.
The RAM to VRAM block copy is generally made by a program in Assembly, who defines the sequence that the blocks are copied. Thus, some animations may result in a very complex program if made this way.
In order to make it easy to create display animations, we create a pointer map after the display code, which contains the blocks sequence to copy from RAM to VRAM. This map is composed by generic pointers to 8x8 pixel blocks. According to that, all that the display code has to do is read the map, get the block number and copy it to VRAM.
Once screen 2 has 768 8x8 pixels blocks, we need 2 bytes to represent each address. So, the resulting map will take 1536 bytes.
The map contains values from &H0000 up to &H17F8 (767 x 8), stepping by 8. This sequence values follows the screen 2 structure pattern, but for 8x8 pixels. See the next diagram with the pointers values following the natural screen 2 block sequence.
MSX Screen 2: col 0 col 1 col 2 col 3 ... col31 +---------------------------------+ |0000H 0008H 0010H 0018H ... 00F8H| Line 0 |0100H 0108H 0110H 0118H ... 01F8H| Line 1 ... ... ... ... ... ...As soon as we change this sequence on the map, we are creating our own animation.
It is important to set a delay between each block tranfer, in order to make this effect more visible. The dalay may be introduced between each block or a set of blocks transfer (frame).
When a value is read from the map, it is converted to RAM/VRAM pattern and RAM/VRAM color addresses. See the next example.
E = MAP(pos) RAM_PAT = E + &H9000 VRAM_PAT = E RAM_COLOR = E + &HA800 VRAM_COLOR = E + &H2000
How to generate a map
The map can be generated by using 32x24 pixel images showing the display progress. A program may be created to convert the progress images to map.
We read the images in sequence, always calculating the difference image from current and previous image. The resulting pixels are the new block pointers to be inserted in the map.
So, we insert the new elements found in the map array.
The display maps have examples on how to create animations.
Engenheiro de Sistemas e Computação
Especialista em Processamento de Imagens e Inteligência Artificial
© MarMSX 1999-2021