What is FastDMA? --------------- FastDMA makes it easy to transfer disjointed data in groups of bytes. FDMA easily renders an entire character or sprite in one go and at the same time can zoom it in the X-axis. How does FDMA work? ----------------- FDMA requires to operate at least: BLOCK LENGTH - the total number of bytes that will be transferred BATCH LENGTH - how many bytes will be transferred in the batch, and SKIP LENGTH - how many bytes will be skipped, i.e. added after the batch is transferred These parameters are set separately for the source address (SOURCE) and separately for the destination (DESTINATION). The transfer batch is repeated until the total number of bytes is used. Example of a character transmission: Batch=8 ... the character has 8 bytes Batch=1 ... one byte Skip=31 ... jump to the next line (line is 32 bytes, 1 byte is transmitted, 31B skipped) Batch Source Target Bytes transferred 1 chrsrc+0 scrdest+0 1 2 chrsrc+1 scrdest+32 1 (32=skip+batch) 3 chrsrc+2 scrdest+48 1 etc. Transmission parameters of a sprite, 32x32 pixels Block=128 4*32 bytes Batch=4 1 line Skip=28 rest to next line position How to program FDMA? -------------------- 1. use the ZXi port g_ZXi_041 to set the address where memory-registers should be 2. write values to memory-registers locations, to set the FDMA parameters 3. the last value to be set (written) is always the first (zero) memory-register - this writing starts the FDMA transfer All FDMA memory-registers (like HGFX and SDMA) are responding to changes, i.e. writes to memory cells, not to reads. Do I have to set everything up again before each transfer? ---------------------------------------------------------- No, only some memory-registers can be set. What if the source and destination are different, in the number of bytes to be to be transferred? Which parameters apply? ------------------------------------------------- Only those parameters are to be transferred that fit into the total number of bytes. BLOCK LENGTH is common. What does "Keep/change value after transfer" mean? -------------------------------------------------- The CHANGE setting means that after each batch transfer the original value is returned to the register without having to set it again. The KEEP setting means to continue where the previous transfer stopped. What is floating? --------------- Floating means SKIP, which contains a decimal point. It can be used to add decimal values to a source or to a target. For example: Chunky image at address 0 with a width of 64 px (64 bytes). The first line is transfered with settings Source=0 Skip (source)=0.5 (0x0080 ... 128/256) Skip (destination)=1 (0x0100 ... 256/256) Destination=address of the chunky video Length=128 SKIP LENGTH is two bytes, like the last source and destination registers, incremented by a value greater than 256. The line of the transferred image is rendered at 2x magnification, as each pixel from the source is to two adjacent pixels on the screen. Example of 4x magnification: Copy pixel from 0,0, set SKIP to 0040 at source, so source=0.25 to keep the read 4 times the same byte. Destination must be 0x0100, for +=1 pixel after transfer. The first pixel will be read from 0.00(X1) ,0(Y) and written to 0(X2),0(Y) This will cause a "stretch" on each single pixel is copied in the batch. While the source remains the same (due to 0.25*256 to 0.75*256 still being copied from the same byte), 0x0100*256 for destination will always cause a move to the next byte. byte skip byte X1 X2 0 > 0 0 0.25 > 1 0 0.50 > 2 0 0.75 > 3 the next pixel to be transferred will be read from the next byte (X1 + 1), because 1 1.00 > 4 1 1.25 > 5 1 1.50 > 6 1 ...etc. How fast is DMA on a 20MHz processor? ------------------------------------- FDMA always runs at the maximum speed the memory will allow. CPU speed has no effect on FDMA. If all the SoundDMA channels are in use, the FDMA speed is reduced.