mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
56 lines
2.6 KiB
C
56 lines
2.6 KiB
C
#ifndef GUARD_DMA3_H
|
|
#define GUARD_DMA3_H
|
|
|
|
// Maximum amount of data we will transfer in one operation
|
|
#define MAX_DMA_BLOCK_SIZE 0x1000
|
|
|
|
#define Dma3CopyLarge_(src, dest, size, bit) \
|
|
{ \
|
|
const void *_src = src; \
|
|
void *_dest = dest; \
|
|
u32 _size = size; \
|
|
while (1) \
|
|
{ \
|
|
if (_size <= MAX_DMA_BLOCK_SIZE) \
|
|
{ \
|
|
DmaCopy##bit(3, _src, _dest, _size); \
|
|
break; \
|
|
} \
|
|
DmaCopy##bit(3, _src, _dest, MAX_DMA_BLOCK_SIZE); \
|
|
_src += MAX_DMA_BLOCK_SIZE; \
|
|
_dest += MAX_DMA_BLOCK_SIZE; \
|
|
_size -= MAX_DMA_BLOCK_SIZE; \
|
|
} \
|
|
}
|
|
|
|
#define Dma3CopyLarge16_(src, dest, size) Dma3CopyLarge_(src, dest, size, 16)
|
|
#define Dma3CopyLarge32_(src, dest, size) Dma3CopyLarge_(src, dest, size, 32)
|
|
|
|
#define Dma3FillLarge_(value, dest, size, bit) \
|
|
{ \
|
|
void *_dest = dest; \
|
|
u32 _size = size; \
|
|
while (1) \
|
|
{ \
|
|
if (_size <= MAX_DMA_BLOCK_SIZE) \
|
|
{ \
|
|
DmaFill##bit(3, value, _dest, _size); \
|
|
break; \
|
|
} \
|
|
DmaFill##bit(3, value, _dest, MAX_DMA_BLOCK_SIZE); \
|
|
_dest += MAX_DMA_BLOCK_SIZE; \
|
|
_size -= MAX_DMA_BLOCK_SIZE; \
|
|
} \
|
|
}
|
|
|
|
#define Dma3FillLarge16_(value, dest, size) Dma3FillLarge_(value, dest, size, 16)
|
|
#define Dma3FillLarge32_(value, dest, size) Dma3FillLarge_(value, dest, size, 32)
|
|
|
|
void ClearDma3Requests(void);
|
|
void ProcessDma3Requests(void);
|
|
s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode);
|
|
s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode);
|
|
s16 CheckForSpaceForDma3Request(s16 index);
|
|
|
|
#endif // GUARD_DMA3_H
|