SNES DMA (Direct Memory Access). More...
#include <snes/types.h>Go to the source code of this file.
Functions | |
| void | dmaClearVRAM (void) |
| Clear all VRAM to zero. | |
| void | dmaCopyCGram (const u8 *source, u16 startColor, u16 size) |
| Copy palette data to CGRAM (PVSnesLib compatible). | |
| void | dmaCopyCGramBank (const u8 *source, u8 bank, u16 startColor, u16 size) |
| Copy palette data to CGRAM with explicit source bank byte. | |
| void | dmaCopyOam (const u8 *source, u16 size) |
| Copy OAM data (PVSnesLib compatible). | |
| void | dmaCopyVram (const u8 *source, u16 vramAddr, u16 size) |
| Copy data to VRAM (PVSnesLib compatible). | |
| void | dmaCopyVramBank (const u8 *source, u8 bank, u16 vramAddr, u16 size) |
| Copy data to VRAM with explicit source bank byte. | |
| void | dmaCopyVramMode7 (const u8 *tilemap, u16 tilemapSize, const u8 *tiles, u16 tilesSize) |
| Load Mode 7 interleaved data to VRAM. | |
| void | dmaFillVRAM (u16 value, u16 dest, u16 size) |
| Set VRAM to a value. | |
| void | dmaTransfer (u8 channel, u8 mode, u8 srcBank, u16 srcAddr, u8 destReg, u16 size) |
| Perform generic DMA transfer. | |
SNES DMA (Direct Memory Access).
Functions for fast memory transfers using DMA.
DMA allows fast transfers between:
DMA is much faster than CPU copying and should be used for all bulk transfers during VBlank.
This header claimed the opposite ("source data must be in bank $00") long after it stopped being true, and that prose is why the RPG template shipped a pointless semifree bank 0 section for its palettes — and why issue #122 carried a bank-$00 claim about dmaCopyCGram that testing then had to retract.
| void dmaClearVRAM | ( | void | ) |
Clear all VRAM to zero.
Clears all 64KB of VRAM. Should be called during force blank.
Copy palette data to CGRAM (PVSnesLib compatible).
Copies palette data from ROM or RAM to CGRAM using DMA.
| source | Source address (can be ROM or RAM) |
| startColor | Starting color index (0-255) |
| size | Number of bytes to copy (2 bytes per color) |
source's own bank byte: a palette may live in any bank. dmaCopyCGramBank() exists for the case where the address and the bank are held separately. Copy palette data to CGRAM with explicit source bank byte.
Same as dmaCopyCGram() but allows specifying the ROM bank for data in banks other than $00 (e.g., SUPERFREE sections placed by linker).
| source | Source address (16-bit offset within bank) |
| bank | Source bank byte ($00-$3F for LoROM, $00-$7D for HiROM) |
| startColor | Starting color index (0-255) |
| size | Number of bytes to transfer (2 bytes per color) |
Copy OAM data (PVSnesLib compatible).
| source | Source address (544 bytes) |
| size | Number of bytes to copy (usually 544) |
Copy data to VRAM (PVSnesLib compatible).
Copies data from ROM or RAM to VRAM using DMA. This function handles 24-bit source addresses, so it works with ROM data defined via extern.
| source | Source address (can be ROM or RAM) |
| vramAddr | Destination word address in VRAM |
| size | Number of bytes to copy |
Forced blank means setScreenOff() — INIDISP bit 7. setBrightness(0) blacks the screen but leaves the PPU fetching, so it does NOT open the write window.
source's own bank byte, so the data may live in ANY bank — a SUPERFREE section, a bank you pinned yourself. dmaCopyVramBank() exists for the case where the address and the bank are held separately. Copy data to VRAM with explicit source bank byte.
Same as dmaCopyVram() but allows specifying the ROM bank for data in banks other than $00 (e.g., SUPERFREE sections placed by linker).
| source | Source address (16-bit offset within bank) |
| bank | Source bank byte ($00-$3F for LoROM, $00-$7D for HiROM) |
| vramAddr | VRAM destination word address |
| size | Number of bytes to transfer |
Load Mode 7 interleaved data to VRAM.
Mode 7 stores tilemap in VRAM low bytes and tile pixels in VRAM high bytes. This function performs two DMA transfers with appropriate VMAIN settings:
VRAM destination is always $0000 (Mode 7 uses the full 32K word space).
| tilemap | Tilemap data source (.mp7 file, 128x128 = 16384 bytes) |
| tilemapSize | Tilemap data size in bytes |
| tiles | Tile pixel data source (.pc7 file, 256 tiles x 64 bytes) |
| tilesSize | Tile pixel data size in bytes |
Set VRAM to a value.
| value | Value to fill (repeated as word) |
| dest | Destination word address in VRAM |
| size | Number of bytes to fill — 0 means 65536 (the full VRAM), which is how dmaClearVRAM() uses it |