PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
dma.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------------
2 
3  Copyright (C) 2012-2017
4  Alekmaul
5 
6 
7  This software is provided 'as-is', without any express or implied
8  warranty. In no event will the authors be held liable for any
9  damages arising from the use of this software.
10 
11  Permission is granted to anyone to use this software for any
12  purpose, including commercial applications, and to alter it and
13  redistribute it freely, subject to the following restrictions:
14 
15  1. The origin of this software must not be misrepresented; you
16  must not claim that you wrote the original software. If you use
17  this software in a product, an acknowledgment in the product
18  documentation would be appreciated but is not required.
19 
20  2. Altered source versions must be plainly marked as such, and
21  must not be misrepresented as being the original software.
22 
23  3. This notice may not be removed or altered from any source
24  distribution.
25 
26 ---------------------------------------------------------------------------------*/
31 #ifndef SNES_DMA_INCLUDE
32 #define SNES_DMA_INCLUDE
33 
34 #include <snes/snestypes.h>
35 
36 #include <snes/background.h>
37 #include <snes/sprite.h>
38 #include <snes/video.h>
39 
41 #define HDMA_CHANNEL0 (1 << 0)
42 #define HDMA_CHANNEL1 (1 << 1)
43 #define HDMA_CHANNEL2 (1 << 2)
44 #define HDMA_CHANNEL3 (1 << 3)
45 #define HDMA_CHANNEL4 (1 << 4)
46 #define HDMA_CHANNEL5 (1 << 5)
47 #define HDMA_CHANNEL6 (1 << 6)
48 #define HDMA_CHANNEL7 (1 << 7)
49 #define HDMA_CHANNELALL (HDMA_CHANNEL0 | HDMA_CHANNEL1 | HDMA_CHANNEL2 | HDMA_CHANNEL3 | HDMA_CHANNEL4 | HDMA_CHANNEL5 | HDMA_CHANNEL6 | HDMA_CHANNEL7)
50 
52 #define MSWIN_BG1 (1 << 0)
53 #define MSWIN_BG2 (1 << 1)
54 #define MSWIN_BG3 (1 << 2)
55 #define MSWIN_BG4 (1 << 3)
57 #define MSWIN1_BG1MSKOUT (1 << 0)
58 #define MSWIN1_BG1MSKENABLE (2 << 0)
59 #define MSWIN2_BG1MSKOUT (1 << 2)
60 #define MSWIN2_BG1MSKENABLE (2 << 2)
61 #define MSWIN1_BG2MSKOUT (1 << 4)
62 #define MSWIN1_BG2MSKENABLE (2 << 4)
63 #define MSWIN2_BG2MSKOUT (1 << 4)
64 #define MSWIN2_BG2MSKENABLE (2 << 4)
65 #define MSWIN1_BG3MSKOUT (1 << 0)
66 #define MSWIN1_BG3MSKENABLE (2 << 0)
67 #define MSWIN2_BG3MSKOUT (1 << 2)
68 #define MSWIN2_BG3MSKENABLE (2 << 2)
69 #define MSWIN1_BG4MSKOUT (1 << 4)
70 #define MSWIN1_BG4MSKENABLE (2 << 4)
71 #define MSWIN2_BG4MSKOUT (1 << 4)
72 #define MSWIN2_BG4MSKENABLE (2 << 4)
75 #define DMA_ENABLE 1
76 
77 typedef struct dmaMemory
78 {
79  union
80  {
81  struct
82  {
83  unsigned short addr;
84  unsigned char bank;
85  unsigned char __pad;
86  } c;
87  void *p;
88  } mem;
89 } dmaMemory;
90 
105 #define REG_MDMAEN (*(vuint8 *)0x420B)
106 
112 #define REG_HDMAEN (*(vuint8 *)0x420C)
113 
140 #define REG_DMAP0 (*(vuint8 *)0x4300)
141 #define REG_DMAP1 (*(vuint8 *)0x4310)
142 #define REG_DMAP2 (*(vuint8 *)0x4320)
143 #define REG_DMAP3 (*(vuint8 *)0x4330)
144 #define REG_DMAP4 (*(vuint8 *)0x4340)
145 #define REG_DMAP5 (*(vuint8 *)0x4350)
146 #define REG_DMAP6 (*(vuint8 *)0x4360)
147 #define REG_DMAP7 (*(vuint8 *)0x4370)
148 
161 #define REG_BBAD0 (*(vuint8 *)0x4301)
162 #define REG_BBAD1 (*(vuint8 *)0x4311)
163 #define REG_BBAD2 (*(vuint8 *)0x4321)
164 #define REG_BBAD3 (*(vuint8 *)0x4331)
165 #define REG_BBAD4 (*(vuint8 *)0x4341)
166 #define REG_BBAD5 (*(vuint8 *)0x4351)
167 #define REG_BBAD6 (*(vuint8 *)0x4361)
168 #define REG_BBAD7 (*(vuint8 *)0x4371)
169 
199 #define REG_A1T0LH (*(vuint16 *)0x4302)
200 #define REG_A1T1LH (*(vuint16 *)0x4312)
201 #define REG_A1T2LH (*(vuint16 *)0x4322)
202 #define REG_A1T3LH (*(vuint16 *)0x4332)
203 #define REG_A1T4LH (*(vuint16 *)0x4342)
204 #define REG_A1T5LH (*(vuint16 *)0x4352)
205 #define REG_A1T6LH (*(vuint16 *)0x4362)
206 #define REG_A1T7LH (*(vuint16 *)0x4372)
207 
208 #define REG_A1B0 (*(vuint8 *)0x4304)
209 #define REG_A1B1 (*(vuint8 *)0x4314)
210 #define REG_A1B2 (*(vuint8 *)0x4324)
211 #define REG_A1B3 (*(vuint8 *)0x4334)
212 #define REG_A1B4 (*(vuint8 *)0x4344)
213 #define REG_A1B5 (*(vuint8 *)0x4354)
214 #define REG_A1B6 (*(vuint8 *)0x4364)
215 #define REG_A1B7 (*(vuint8 *)0x4374)
216 
237 #define REG_DAS0LH (*(vuint16 *)0x4305)
238 #define REG_DAS1LH (*(vuint16 *)0x4315)
239 #define REG_DAS2LH (*(vuint16 *)0x4325)
240 #define REG_DAS3LH (*(vuint16 *)0x4335)
241 #define REG_DAS4LH (*(vuint16 *)0x4345)
242 #define REG_DAS5LH (*(vuint16 *)0x4355)
243 #define REG_DAS6LH (*(vuint16 *)0x4365)
244 #define REG_DAS7LH (*(vuint16 *)0x4375)
245 
246 extern u8 HDMATable16[224 + 1];
254 void dmaCopyCGram(u8 *source, u16 address, u16 size);
255 
262 void dmaCopyVram(u8 *source, u16 address, u16 size);
263 
269 void dmaCopySpr32Vram(u8 *source, u16 address);
270 
276 void dmaCopySpr16Vram(u8 *source, u16 address);
277 
284 void dmaFillVram(u8 *source, u16 address, u16 size);
285 
289 void dmaClearVram(void);
290 
297 void dmaCopyOAram(u8 *source, u16 address, u16 size);
298 
307 void dmaCopyVram7(u8 *source, u16 address, u16 size, u8 vrammodeinc, u16 dmacontrol);
308 
313 void setModeHdmaGradient(u8 maxLevels);
314 
319 
324 void setModeHdmaShading(unsigned char mode);
325 
333 void setParallaxScrolling(u8 bgrnd);
334 
339 void setModeHdmaReset(u8 channels);
340 
345 void setModeHdmaWindowReset(u8 channels);
346 
351 void setModeHdmaColor(u8* hdmatable);
352 
357 void setModeHdmaWaves(u8 bgrnd);
358 
363 
371 void setModeHdmaWindow(u8 bgrnd, u8 bgrndmask,u8* hdmatableL,u8* hdmatableR);
372 
373 #endif // SNES_DMA_INCLUDE
snes background defines and functionality.
void setModeHdmaShading(unsigned char mode)
Do a shading effect on screen. Use HDMA Channels 0 to 2.
void dmaFillVram(u8 *source, u16 address, u16 size)
fill the source data to destination using channel 0 of DMA available channels in half words
void dmaCopySpr16Vram(u8 *source, u16 address)
copy sprite 16pix size data from source to destination using channel 0 of DMA available channels in h...
void setModeHdmaWindowReset(u8 channels)
Reset or Set HDMA channels and remove WINDOW effect.
void setModeHdmaShadeUpDown(void)
Do a brightness gradient from up/down to center of the screen. Use HDMA Channels 3.
void dmaClearVram(void)
clear all vram data with #0
void dmaCopyOAram(u8 *source, u16 address, u16 size)
copies Sprites from source to destination using channel 0 of DMA available channels in half words
void setModeHdmaColor(u8 *hdmatable)
Do a color gradient effect on screen (with color 0). Use HDMA Channels 6.
void setModeHdmaReset(u8 channels)
Reset or Set HDMA channels.
void setParallaxScrolling(u8 bgrnd)
Do a parallax scrolling effect on screen. Use HDMA Channels 3.
void setModeHdmaWaves(u8 bgrnd)
Do a waves effect on screen (init function). Use HDMA Channels 6.
void dmaCopySpr32Vram(u8 *source, u16 address)
copy sprite 32pix size data from source to destination using channel 0 of DMA available channels in h...
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 V...
void setModeHdmaGradient(u8 maxLevels)
Do a brightness gradient on screen. Use HDMA Channels 3.
u8 HDMATable16[224+1]
HDMA table accessible to change values.
void setModeHdmaWavesMove(void)
Animate the waves effect. Must be called during each frame. setModeHdmaWaves must have been done to ...
void dmaCopyVram(u8 *source, u16 address, u16 size)
copy data from source to destination using channel 0 of DMA available channels in half words
void dmaCopyCGram(u8 *source, u16 address, u16 size)
copy data from source to destination using channel 0 of DMA available channels in half words
Custom types used by libsnes.
snes sprites functionality.
contains the basic definitions for controlling the video hardware.