PVSnesLib  3.4.0
Macros | Functions
dma.h File Reference

Wrapper functions for direct memory access hardware. More...

#include <snes/snestypes.h>
#include <snes/background.h>
#include <snes/sprite.h>
#include <snes/video.h>

Go to the source code of this file.

Macros

#define DMA_ENABLE   1
 Bit defines for the DMA control registers.
 
#define REG_A1B7   (*(vuint8*)0x4374)
 A1TxL - HDMA Table Start Address (low) / DMA Current Addr (low) (R/W) A1TxH - HDMA Table Start Address (hi) / DMA Current Addr (hi) (R/W) A1Bx - HDMA Table Start Address (bank) / DMA Current Addr (bank) (R/W) More...
 
#define REG_BBAD7   (*(vuint8*)0x4371)
 DMA/HDMA I/O-Bus Address (PPU-Bus aka B-Bus) (R/W) For both DMA and HDMA: 7-0 B-Bus Address (selects an I/O Port which is mapped to 2100h-21FFh)
 
#define REG_DAS7LH   (*(vuint16*)0x4375)
 Indirect HDMA Address (low) / DMA Byte-Counter (low) (R/W) DASxL - Indirect HDMA Address (low) / DMA Byte-Counter (low) (R/W) DASxH - Indirect HDMA Address (hi) / DMA Byte-Counter (hi) (R/W) 43x7h - DASBx - Indirect HDMA Address (bank) (R/W) More...
 
#define REG_HDMAEN   (*(vuint8*)0x420C)
 Select H-Blank DMA (H-DMA) Channel(s) (W) 7-0 H-DMA Channel 7-0 Enable (0=Disable, 1=Enable)
 
#define REG_MDMAEN   (*(vuint8*)0x420B)
 Select General Purpose DMA Channel(s) and Start Transfer (W) 7-0 General Purpose DMA Channel 7-0 Enable (0=Disable, 1=Enable) More...
 

Functions

void dmaClearVram (void)
 clear all vram data with #0
 
void dmaCopyCGram (u8 *source, u16 address, u16 size)
 copy data from source to destination using channel 0 of DMA available channels in half words More...
 
void dmaCopyOAram (u8 *source, u16 address, u16 size)
 copies Sprites from source to destination using channel 0 of DMA available channels in half words More...
 
void dmaCopySpr16Vram (u8 *source, u16 address)
 copy sprite 16pix size data from source to destination using channel 0 of DMA available channels in half words More...
 
void dmaCopySpr32Vram (u8 *source, u16 address)
 copy sprite 32pix size data from source to destination using channel 0 of DMA available channels in half words More...
 
void dmaCopyVram (u8 *source, u16 address, u16 size)
 copy data from source to destination using channel 0 of DMA available channels in half words More...
 
void dmaCopyVram7 (u8 *source, u16 address, u16 size, u8 vrammodeinc, u16 dmacontrol)
 copies data from source to destination using channel 0 of DMA available channels in half words with VMAIN value More...
 
void dmaFillVram (u8 *source, u16 address, u16 size)
 fill the source data to destination using channel 0 of DMA available channels in half words More...
 
void setModeHdmaGradient (u8 maxLevels)
 Do a brightness gradient on screen. More...
 
void setModeHdmaShadeUpDown (void)
 Do a brightness gradient from up/down to center of the screen.
 
void setModeHdmaShading (unsigned char mode)
 Do a shading effect on screen. More...
 

Detailed Description

Wrapper functions for direct memory access hardware.

Macro Definition Documentation

◆ REG_A1B7

#define REG_A1B7   (*(vuint8*)0x4374)

A1TxL - HDMA Table Start Address (low) / DMA Current Addr (low) (R/W) A1TxH - HDMA Table Start Address (hi) / DMA Current Addr (hi) (R/W) A1Bx - HDMA Table Start Address (bank) / DMA Current Addr (bank) (R/W)

For normal DMA: 23-16 CPU-Bus Data Address Bank (constant, not incremented/decremented) 15-0 CPU-Bus Data Address (incremented/decremented/fixed, as selected)

For HDMA: 23-16 CPU-Bus Table Address Bank (constant, bank number for 43x8h/43x9h) 15-0 CPU-Bus Table Address (constant, reload value for 43x8h/43x9h)

◆ REG_DAS7LH

#define REG_DAS7LH   (*(vuint16*)0x4375)

Indirect HDMA Address (low) / DMA Byte-Counter (low) (R/W) DASxL - Indirect HDMA Address (low) / DMA Byte-Counter (low) (R/W) DASxH - Indirect HDMA Address (hi) / DMA Byte-Counter (hi) (R/W) 43x7h - DASBx - Indirect HDMA Address (bank) (R/W)

For normal DMA: 23-16 Not used 15-0 Number of bytes to be transferred (1..FFFFh=1..FFFFh, or 0=10000h) (This is really a byte-counter; with a 4-byte "Transfer Unit", len=5 would transfer one whole Unit, plus the first byte of the second Unit.) (The 16bit value is decremented during transfer, and contains 0000h on end.)

◆ REG_MDMAEN

#define REG_MDMAEN   (*(vuint8*)0x420B)

Select General Purpose DMA Channel(s) and Start Transfer (W) 7-0 General Purpose DMA Channel 7-0 Enable (0=Disable, 1=Enable)

When writing a non-zero value to this register, general purpose DMA will be started immediately (after a few clk cycles). The CPU is paused during the transfer. The transfer can be interrupted by H-DMA transfers. If more than 1 bit is set in MDMAEN, then the separate transfers will be executed in WHICH? priority order. The MDMAEN bits are cleared automatically at transfer completion. Do not use channels for GP-DMA which are activated as H-DMA in HDMAEN.

Function Documentation

◆ dmaCopyCGram()

void dmaCopyCGram ( u8 *  source,
u16  address,
u16  size 
)

copy data from source to destination using channel 0 of DMA available channels in half words

Parameters
sourcethe source to copy from
addresscgram address to copy
sizethe size in bytes of the data to copy.
Examples:
games/breakout/breakout.c.

◆ dmaCopyOAram()

void dmaCopyOAram ( u8 *  source,
u16  address,
u16  size 
)

copies Sprites from source to destination using channel 0 of DMA available channels in half words

Parameters
sourcethe source to copy from
addressvram address to copy
sizethe size in bytes of the data to copy.
Examples:
graphics/Sprites/DynamicSprite/DynamicSprite.c.

◆ dmaCopySpr16Vram()

void dmaCopySpr16Vram ( u8 *  source,
u16  address 
)

copy sprite 16pix size data from source to destination using channel 0 of DMA available channels in half words

Parameters
sourcethe source to copy from
addressvram address to copy

◆ dmaCopySpr32Vram()

void dmaCopySpr32Vram ( u8 *  source,
u16  address 
)

copy sprite 32pix size data from source to destination using channel 0 of DMA available channels in half words

Parameters
sourcethe source to copy from
addressvram address to copy

◆ dmaCopyVram()

void dmaCopyVram ( u8 *  source,
u16  address,
u16  size 
)

copy data from source to destination using channel 0 of DMA available channels in half words

Parameters
sourcethe source to copy from
addressvram address to copy
sizethe size in bytes of the data to copy.
Examples:
games/breakout/breakout.c, games/likemario/LikeMario.c, graphics/Backgrounds/Mode3/Mode3.c, graphics/Effects/HDMAGradient/HDMAGradient.c, and graphics/Sprites/DynamicSprite/DynamicSprite.c.

◆ dmaCopyVram7()

void dmaCopyVram7 ( u8 *  source,
u16  address,
u16  size,
u8  vrammodeinc,
u16  dmacontrol 
)

copies data from source to destination using channel 0 of DMA available channels in half words with VMAIN value

Parameters
sourcethe source to copy from
addressvram address to copy
sizethe size in bytes of the data to copy.
vrammodeincthe value of REG_VMAIN (incr or not incr).
dmacontrolthe value of DMA control register (incr or not incr, $18 or $19, and so on).

◆ dmaFillVram()

void dmaFillVram ( u8 *  source,
u16  address,
u16  size 
)

fill the source data to destination using channel 0 of DMA available channels in half words

Parameters
sourcethe value of source to copy from
addressvram address to copy
sizethe size in bytes of the data to copy.

◆ setModeHdmaGradient()

void setModeHdmaGradient ( u8  maxLevels)

Do a brightness gradient on screen.

Parameters
maxLevelsvalue between 1..15 for the maximum level of brightness (15=light, 1=near dark)
Examples:
graphics/Effects/HDMAGradient/HDMAGradient.c.

◆ setModeHdmaShading()

void setModeHdmaShading ( unsigned char  mode)

Do a shading effect on screen.

Parameters
modevalue 0 disactivate 1, other value activate it