File: gba.inc - Tab length: 1 2 4 8 - Lines: on off - No wrap: on off

001: @@@@@@@@@ CONTENTS @@@@@@@@@
002: @ 1. Key pad defines
003: @ 2. Display
004: @ 3. Sprites
005: @ 4. Background
006: @ 5. Sound
007: @ 6. DMA
008: 
009: @@@@@@@@@ 1. KEY PAD DEFINES @@@@@@@@@
010: KEY_A     = 1
011: KEY_B     = 2
012: KEY_SELECT  = 4
013: KEY_START = 8
014: KEY_RIGHT = 16
015: KEY_LEFT  = 32
016: KEY_UP    = 64
017: KEY_DOWN  = 128
018: KEY_R   = 256
019: KEY_L   = 512
020: KEYS    = 0x04000130
021: KEYS_HIGH = 0x04000000
022: KEYS_LOW  = 0x00000130
023: 
024: @@@@@@@@@ 2. Display @@@@@@@@@
025: @ Tile modes
026: MODE_0 = 0x00 @ All 4 BG layers available, but no rotation/scaling
027: MODE_1 = 0x01 @ 3 BG layers (0-2), BG2 can rotate/scale
028: MODE_2 = 0x02 @ 2 BG layers (2-3), both can scale/rotate
029: @ Bitmap modes : BG2 only
030: MODE_3 = 0x03 @ 16 bit color bitmap, cuts into available sprite data area
031: MODE_4 = 0x04 @ Like Mode 3, but with 8-bit references (and palette)
032: MODE_5 = 0x05 @ 16 bit color bitmap, with backbuffer. Screen limited to 160x128
033: 
034: BACKBUFFER = 0x010
035: H_BLANK_OAM = 0x020
036: 
037: OBJ_MAP_2D = 0x000
038: OBJ_MAP_1D = 0x040
039: 
040: FORCE_BLANK = 0x080
041: 
042: BG0_ENABLE = 0x0100
043: BG1_ENABLE = 0x0200
044: BG2_ENABLE = 0x0400
045: BG3_ENABLE = 0x0800
046: OBJ_ENABLE = 0x01000    @ = SPRITES_ENABLE: enable sprites
047: WIN1_ENABLE = 0x02000
048: WIN2_ENABLE = 0x04000
049: WINOBJ_ENABLE = 0x08000
050: VRAM = 0x06000000
051: VPAL = 0x05000000
052: REG_DISPCNT = 0x04000000  @
053: 
054: @@@@@@@@@ 3. SPRITES @@@@@@@@@
055: 
056: @*** Attribute 0 ***
057: @ F E D C  B A 9 8  7 6 5 4  3 2 1 0
058: @ S S A M  T T D R  J J J J  J J J J
059: @ 0-7 (J) = Y coordinate of the sprite (pixels)
060: @ 8   (R) = Rotation/Scaling on/off
061: @ 9   (D) = 0 - sprite is single sized;
062: @       1 - sprite is virtually double sized
063: @ A-B (T) = 00 - normal
064: @       01 - semi-transparent
065: @       10 - obj window
066: @ C   (M) = enables mosaic for this sprite.
067: @ D   (A) = 256 color if on, 16 color if off
068: @ E-F (S) = Size, MSB in attribute 0, LSB in attribute 1
069: 
070: @ Byte 1 = Y coordinate of the sprite, in pixels
071: @ Byte 2
072: ROTATION_FLAG =  0x100
073: SIZE_DOUBLE   =  0x200
074: MODE_NORMAL   =  0x000
075: MODE_TRANSPERANT=  0x400
076: MODE_WINDOWED =  0x800
077: MOSAIC      = 0x1000
078: COLOR_16    = 0x0000
079: COLOR_256   = 0x2000
080: SIZE_8      = 0x0000 @ Only valid for SQUARE
081: SIZE_16     = 0x4000
082: SIZE_32     = 0x8000
083: SIZE_64     = 0xC000
084: 
085: @*** Atribute 1 ***
086: @ FEDC BA98 7654 3210
087: @ SSVH XXXI IIII IIII (standard sprites)
088: @ SSFF FFFI IIII IIII (rotation/scaling on)
089: @ 0-8 (I) = X coordinate of the sprite (pixels)
090: @ C   (H) = flip horizinal bit
091: @ D   (V) = flip vertical bit
092: @ 9-D (F) = rotation index (0-31). rotation/scaling data in OAM attribute 3
093: @ E-F (S) = Size of the sprite (LSB)
094: @     4-bit value which sets the size of the sprite in the following way:
095: @     00 00: 8  x 8   10 00: 8  x 16
096: @     00 01: 16 x 16    10 01: 8  x 32
097: @     00 10: 32 x 32    10 10: 16 x 32
098: @     00 11: 64 x 64    10 11: 32 x 64
099: @     01 00: 16 x 8   11 00: Not used
100: @     01 01: 32 x 8   11 01: Not used
101: @     01 10: 32 x 16    11 10: Not used
102: @     01 11: 64 x 32    11 11: Not used
103: 
104: @ Byte 3+1 bit = X coordinate of the sprite, in pixels (9-bit value)
105: @ Byte 4
106: SQUARE      = 0x0000
107: WIDE      = 0x4000
108: TALL      = 0x8000
109: HORIZONTAL_FLIP = 0x1000
110: VERTICAL_FLIP = 0x2000
111: OAM       = 0x07000000
112: OBJPAL      = 0x5000200
113: CHARMEM     = 0x6010000
114: CHARMEM_MODE3 = 0x6012BFD
115: 
116: @@@@@@@@@ 4. Background @@@@@@@@@
117: 
118: REG_BG0CNT  = 0x4000008
119: REG_BG1CNT  = 0x400000A
120: REG_BG2CNT  = 0x400000C
121: REG_BG3CNT  = 0x400000E
122: REG_BG0HOFS = 0x4000010
123: REG_BG0VOFS = 0x4000012
124: REG_BG1HOFS = 0x4000014
125: REG_BG1VOFS = 0x4000016
126: REG_BG2HOFS = 0x4000018
127: REG_BG2VOFS = 0x400001A
128: REG_BG3HOFS = 0x400001C
129: REG_BG3VOFS = 0x400001E
130: REG_BG2PA   = 0x4000020
131: REG_BG2PB   = 0x4000022
132: REG_BG2PC   = 0x4000024
133: REG_BG2PD   = 0x4000026
134: REG_BG2X    = 0x4000028
135: REG_BG2X_L  = 0x4000028
136: REG_BG2X_H  = 0x400002A
137: REG_BG2Y    = 0x400002C
138: REG_BG2Y_L  = 0x400002C
139: REG_BG2Y_H  = 0x400002E
140: REG_BG3PA   = 0x4000030
141: REG_BG3PB   = 0x4000032
142: REG_BG3PC   = 0x4000034
143: REG_BG3PD   = 0x4000036
144: REG_BG3X    = 0x4000038
145: REG_BG3X_L  = 0x4000038
146: REG_BG3X_H  = 0x400003A
147: REG_BG3Y    = 0x400003C
148: REG_BG3Y_L  = 0x400003C
149: REG_BG3Y_H  = 0x400003E
150: 
151: BG_MOSAIC_ENABLE = 0x40
152: BG_COLOR_256 = 0x80
153: BG_COLOR_16 = 0x0
154: 
155: TEXTBG_SIZE_256x256 = 0x0
156: TEXTBG_SIZE_256x512 = 0x8000
157: TEXTBG_SIZE_512x256 = 0x4000
158: TEXTBG_SIZE_512x512 = 0xC000
159: 
160: ROTBG_SIZE_128x128 = 0x0
161: ROTBG_SIZE_256x256 = 0x4000
162: ROTBG_SIZE_512x512 = 0x8000
163: ROTBG_SIZE_1024x1024 = 0xC000
164: 
165: WRAPAROUND = 0x2000
166: 
167: CHAR_SHIFT = 2 @ Used to shift the number over to the right place in REG_BGxCNT
168: SCREEN_SHIFT = 8
169: 
170: @ Defines for all 32 screen (map data) blocks and 4 character (bitmap data) blocks
171: @ Some of this might not be correct
172: CHAR_BLOCK_0 = 0x6000000
173: CHAR_BLOCK_1 = 0x6004000
174: CHAR_BLOCK_2 = 0x6008000
175: CHAR_BLOCK_3 = 0x600C000
176: SCREEN_BLOCK_0 = 0x6000000
177: SCREEN_BLOCK_1 = 0x6000800
178: SCREEN_BLOCK_2 = 0x6001000
179: SCREEN_BLOCK_3 = 0x6001800
180: SCREEN_BLOCK_4 = 0x6002000
181: SCREEN_BLOCK_5 = 0x6002800
182: SCREEN_BLOCK_6 = 0x6003000
183: SCREEN_BLOCK_7 = 0x6003800
184: SCREEN_BLOCK_8 = 0x6004000
185: SCREEN_BLOCK_9 = 0x6004800
186: SCREEN_BLOCK_10 = 0x6005000
187: SCREEN_BLOCK_11 = 0x6005800
188: SCREEN_BLOCK_12 = 0x6006000
189: SCREEN_BLOCK_13 = 0x6006800
190: SCREEN_BLOCK_14 = 0x6007000
191: SCREEN_BLOCK_15 = 0x6007800
192: SCREEN_BLOCK_16 = 0x6008000
193: SCREEN_BLOCK_17 = 0x6008800
194: SCREEN_BLOCK_18 = 0x6009000
195: SCREEN_BLOCK_19 = 0x6009800
196: SCREEN_BLOCK_20 = 0x600A000
197: SCREEN_BLOCK_21 = 0x600A800
198: SCREEN_BLOCK_22 = 0x600B000
199: SCREEN_BLOCK_23 = 0x600B800
200: SCREEN_BLOCK_24 = 0x600C000
201: SCREEN_BLOCK_25 = 0x600C800
202: SCREEN_BLOCK_26 = 0x600D000
203: SCREEN_BLOCK_27 = 0x600D800
204: SCREEN_BLOCK_28 = 0x600E000
205: SCREEN_BLOCK_29 = 0x600E800
206: SCREEN_BLOCK_30 = 0x600F000
207: SCREEN_BLOCK_31 = 0x600F800
208: 
209: @@@@@@@@@ 5. Sound @@@@@@@@@
210: @ To turn sound on:
211: @ ldr r1,=REG_SOUNDCNT_X
212: @ ldr r0,=0x0081
213: @ str r0,[r1]
214: 
215: REG_SOUND1CNT_L = 0x04000060 @ Sound 1 Sweep control
216: REG_SOUND1CNT_H = 0x04000062 @ Sound 1 Length, wave duty and envelope control
217: REG_SOUND1CNT_X = 0x04000064 @ Sound 1 Frequency, reset and loop control
218: REG_SOUND2CNT_L = 0x04000068 @ Sound 2 Length, wave duty and envelope control
219: REG_SOUND2CNT_H = 0x0400006C @ Sound 2 Frequency, reset and loop control
220: REG_SOUND3CNT_L = 0x04000070 @ Sound 3 Enable and wave ram bank control
221: REG_SOUND3CNT_H = 0x04000072 @ Sound 3 Sound Length and output level control
222: REG_SOUND3CNT_X = 0x04000074 @ Sound 3 Frequency, reset and loop control
223: REG_SOUND4CNT_L = 0x04000078 @ Sound 4 Length, output level and envelope control
224: REG_SOUND4CNT_H = 0x0400007C @ Sound 4 Noise parameters, reset and loop control
225: REG_SOUNDCNT_L  = 0x04000080 @ Sound 1-4 Output level and Stereo control
226: REG_SOUNDCNT_H  = 0x04000082 @ Direct Sound control and Sound 1-4 output ratio
227: REG_SOUNDCNT_X  = 0x04000084 @ Master sound enable and Sound 1-4 play status
228: REG_SOUNDBIAS = 0x04000088 @ Sound bias and Amplitude resolution control
229: REG_WAVE_RAM0_L = 0x04000090 @ Sound 3 samples 0-3
230: REG_WAVE_RAM0_H = 0x04000092 @ Sound 3 samples 4-7
231: REG_WAVE_RAM1_L = 0x04000094 @ Sound 3 samples 8-11
232: REG_WAVE_RAM1_H = 0x04000096 @ Sound 3 samples 12-15
233: REG_WAVE_RAM2_L = 0x04000098 @ Sound 3 samples 16-19
234: REG_WAVE_RAM2_H = 0x0400009A @ Sound 3 samples 20-23
235: REG_WAVE_RAM3_L = 0x0400009C @ Sound 3 samples 23-27
236: REG_WAVE_RAM3_H = 0x0400009E @ Sound 3 samples 28-31
237: REG_FIFO_A_L  = 0x040000A0 @ Direct Sound channel A samples 0-1
238: REG_FIFO_A_H  = 0x040000A2 @ Direct Sound channel A samples 2-3
239: REG_FIFO_B_L  = 0x040000A4 @ Direct Sound channel B samples 0-1
240: REG_FIFO_B_H  = 0x040000A6 @ Direct Sound channel B samples 2-3
241: 
242: @@@@@@@@@ 6. DMA @@@@@@@@@
243: 
244: DMA_ENABLE  = 0x80000000
245: DMA_INTERUPT_ENABLE = 0x40000000
246: DMA_TIMEING_IMMEDIATE = 0x00000000
247: DMA_TIMEING_VBLANK  = 0x10000000
248: DMA_TIMEING_HBLANK  = 0x20000000
249: DMA_TIMEING_SYNC_TO_DISPLAY = 0x30000000
250: DMA_16  = 0x00000000
251: DMA_32  = 0x04000000
252: DMA_REPEAT  = 0x02000000
253: DMA_SOURCE_INCREMENT  = 0x00000000
254: DMA_SOURCE_DECREMENT  = 0x00800000
255: DMA_SOURCE_FIXED  = 0x01000000
256: DMA_DEST_INCREMENT  = 0x00000000
257: DMA_DEST_DECREMENT  = 0x00200000
258: DMA_DEST_FIXED  = 0x00400000
259: DMA_DEST_RELOAD = 0x00600000
260: 
261: @ register defines, ripped from GBA.h from DevKitAdvanced
262: REG_DMA0SAD   = 0x40000B0
263: REG_DMA0SAD_L = 0x40000B0
264: REG_DMA0SAD_H = 0x40000B2
265: REG_DMA0DAD   = 0x40000B4
266: REG_DMA0DAD_L = 0x40000B4
267: REG_DMA0DAD_H = 0x40000B6
268: REG_DMA0CNT   = 0x40000B8
269: REG_DMA0CNT_L = 0x40000B8
270: REG_DMA0CNT_H = 0x40000BA
271: REG_DMA1SAD   = 0x40000BC
272: REG_DMA1SAD_L = 0x40000BC
273: REG_DMA1SAD_H = 0x40000BE
274: REG_DMA1DAD   = 0x40000C0
275: REG_DMA1DAD_L = 0x40000C0
276: REG_DMA1DAD_H = 0x40000C2
277: REG_DMA1CNT   = 0x40000C4
278: REG_DMA1CNT_L = 0x40000C4
279: REG_DMA1CNT_H = 0x40000C6
280: REG_DMA2SAD   = 0x40000C8
281: REG_DMA2SAD_L = 0x40000C8
282: REG_DMA2SAD_H = 0x40000CA
283: REG_DMA2DAD   = 0x40000CC
284: REG_DMA2DAD_L = 0x40000CC
285: REG_DMA2DAD_H = 0x40000CE
286: REG_DMA2CNT   = 0x40000D0
287: REG_DMA2CNT_L = 0x40000D0
288: REG_DMA2CNT_H = 0x40000D2
289: REG_DMA3SAD   = 0x40000D4
290: REG_DMA3SAD_L = 0x40000D4
291: REG_DMA3SAD_H = 0x40000D6
292: REG_DMA3DAD   = 0x40000D8
293: REG_DMA3DAD_L = 0x40000D8
294: REG_DMA3DAD_H = 0x40000DA
295: REG_DMA3CNT   = 0x40000DC
296: REG_DMA3CNT_L = 0x40000DC
297: REG_DMA3CNT_H = 0x40000DE
298: 
299: @ These defines group common options to save typing
300: @ You may notice that I don't have to include the option to increment the source and address register as that is the default.
301: @ DMA_32NOW DMA_ENABLE|DMA_TIMEING_IMMEDIATE|DMA_32
302: @ DMA_16NOW DMA_ENABLE|DMA_TIMEING_IMMEDIATE|DMA_16
303: DMA_32NOW = 0x84000000
304: DMA_16NOW = 0x80000000