blob: 2efe715886c18de208604005c7cded73902a95e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
(*
$Id$
------------------------------------------------------------------------------
Header file for libgba sprite definitions
Copyright 2003-2006 by Dave Murphy.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
Please report all bugs and problems through the bug tracker at
"http://sourceforge.net/tracker/?group_id=114505&atid=668551".
------------------------------------------------------------------------------
Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
(http://www.freepascal.org)
Copyright (C) 2006 Francesco Lombardi
Check http://sourceforge.net/projects/libndsfpc for updates
------------------------------------------------------------------------------
$Log$
*)
{$ifdef GBA_INTERFACE}
type
OBJATTR = record
attr0: u16;
attr1: u16;
attr2: u16;
dummy: u16;
end;
POBJATTR = ^OBJATTR;
SpriteEntry = record
attribute: array [0..2] of u16;
dummy: u16;
end;
PSpriteEntry = ^SpriteEntry;
OBJAFFINE = record
dummy0: array [0..2] of u16;
pa: s16;
dummy1: array [0..2] of u16;
pb: s16;
dummy2: array [0..2] of u16;
pc: s16;
dummy3: array [0..2] of u16;
pd: s16;
end;
POBJAFFINE = ^OBJAFFINE;
const
OAM : POBJATTR = pointer($07000000);
OBJ_BASE_ADR = pointer(VRAM + $10000);
SPRITE_GFX : pu16 = pointer(VRAM + $10000);
BITMAP_OBJ_BASE_ADR = pointer(VRAM + $14000);
type
SPRITE_SHAPES = integer;
const
SQUARE: SPRITE_SHAPES = 0;
WIDE: SPRITE_SHAPES = 1;
TALL: SPRITE_SHAPES = 2;
function OBJ_SHAPE(m: integer): integer; inline;
// Sprite Attribute 0
function OBJ_Y(m: integer): integer; inline;
const
OBJ_ROT_SCALE_ON = (1 shl 8);
OBJ_DISABLE = (1 shl 9);
OBJ_DOUBLE = (1 shl 9);
function OBJ_MODE(m: integer): integer; inline;
const
OBJ_MOSAIC = (1 shl 12);
OBJ_256_COLOR = (1 shl 13);
OBJ_16_COLOR = (0 shl 13);
ATTR0_MOSAIC = (1 shl 12);
ATTR0_COLOR_256 = (1 shl 13);
ATTR0_COLOR_16 = (0 shl 13);
ATTR0_NORMAL = (0 shl 8);
ATTR0_ROTSCALE = (1 shl 8);
ATTR0_DISABLED = (2 shl 8);
ATTR0_ROTSCALE_DOUBLE = (3 shl 8);
{$define ATTR0_SQUARE := OBJ_SHAPE(SQUARE)}
{$define ATTR0_WIDE := OBJ_SHAPE(WIDE)}
{$define ATTR0_TALL := OBJ_SHAPE(TALL)}
// Sprite Attribute 1
function OBJ_X(m: integer): integer; inline;
function OBJ_ROT_SCALE(m: integer): integer; inline;
const
OBJ_HFLIP = (1 shl 12);
OBJ_VFLIP = (1 shl 13);
function ATTR1_ROTDATA(n: integer): integer; inline;
const
ATTR1_FLIP_X = (1 shl 12);
ATTR1_FLIP_Y = (1 shl 13);
ATTR1_SIZE_8 = (0 shl 14);
ATTR1_SIZE_16 = (1 shl 14);
ATTR1_SIZE_32 = (2 shl 14);
ATTR1_SIZE_64 = (3 shl 14);
function OBJ_SIZE(m: integer): integer; inline;
// Sprite Attribute 2
function OBJ_CHAR(m: integer): integer; inline;
function OBJ_PRIORITY(m: integer): integer; inline;
function OBJ_PALETTE(m: integer): integer; inline;
function ATTR2_PRIORITY(n: integer): integer; inline;
function ATTR2_PALETTE(n: integer): integer; inline;
{$define OBJ_TRANSLUCENT := OBJ_MODE(1)}
{$define OBJ_OBJWINDOW := OBJ_MODE(2)}
{$define OBJ_SQUARE := OBJ_SHAPE(0)}
{$define OBJ_WIDE := OBJ_SHAPE(1)}
{$define OBJ_TALL := OBJ_SHAPE(2)}
//---------------------------------------------------------------------------------
type
SPRITE_SIZECODE = integer;
const
Sprite_8x8 : SPRITE_SIZECODE = 0;
Sprite_16x16: SPRITE_SIZECODE = 1;
Sprite_32x32: SPRITE_SIZECODE = 2;
Sprite_64x64: SPRITE_SIZECODE = 3;
Sprite_16x8 : SPRITE_SIZECODE = 4;
Sprite_32x8 : SPRITE_SIZECODE = 5;
Sprite_32x16: SPRITE_SIZECODE = 6;
Sprite_64x32: SPRITE_SIZECODE = 7;
Sprite_8x16 : SPRITE_SIZECODE = 8;
Sprite_8x32 : SPRITE_SIZECODE = 9;
Sprite_16x32: SPRITE_SIZECODE = 10;
Sprite_32x64: SPRITE_SIZECODE = 11;
{$endif GBA_INTERFACE}
{$ifdef GBA_IMPLEMENTATION}
function OBJ_SHAPE(m: integer): integer; inline;
begin
OBJ_SHAPE := ((m) shl 14);
end;
// Sprite Attribute 0
function OBJ_Y(m: integer): integer; inline;
begin
OBJ_Y := ((m) and $00ff);
end;
function OBJ_MODE(m: integer): integer; inline;
begin
OBJ_MODE := ((m) shl 10);
end;
// Sprite Attribute 1
function OBJ_X(m: integer): integer; inline;
begin
OBJ_X := ((m) and $01ff);
end;
function OBJ_ROT_SCALE(m: integer): integer; inline;
begin
OBJ_ROT_SCALE := ((m) shl 9);
end;
function ATTR1_ROTDATA(n: integer): integer; inline;
begin
ATTR1_ROTDATA := ((n) shl 9); // note: overlaps with flip flags
end;
function OBJ_SIZE(m: integer): integer; inline;
begin
OBJ_SIZE := ((m) shl 14);
end;
// Sprite Attribute 2
function OBJ_CHAR(m: integer): integer; inline;
begin
OBJ_CHAR := ((m) and $03ff);
end;
function OBJ_PRIORITY(m: integer): integer; inline;
begin
OBJ_PRIORITY := ((m) shl 10);
end;
function OBJ_PALETTE(m: integer): integer; inline;
begin
OBJ_PALETTE := ((m) shl 12);
end;
function ATTR2_PRIORITY(n: integer): integer; inline;
begin
ATTR2_PRIORITY := ((n) shl 10);
end;
function ATTR2_PALETTE(n: integer): integer; inline;
begin
ATTR2_PALETTE := ((n) shl 12);
end;
{$endif GBA_IMPLEMENTATION}
|