-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hardware.h
710 lines (617 loc) · 26.3 KB
/
Hardware.h
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
#ifndef __HARDWARE_H__
#define __HARDWARE_H__
#define MEM16(addr) ((uint16_t *)(addr))
#define REG8(addr) (*(volatile uint8_t *)(addr))
#define REG16(addr) (*(volatile uint16_t *)(addr))
#define REG32(addr) (*(volatile uint32_t *)(addr))
#define REGPTR(addr) (*(volatile void **)(addr))
//
// Memory regions
//
#ifdef VRAM_A
#undef VRAM_A
#undef VRAM_B
#endif
#define PALRAM_A MEM16(0x05000000)
#define PALRAM_OBJ_A MEM16(0x05000200)
#define PALRAM_B MEM16(0x05000400)
#define PALRAM_OBJ_B MEM16(0x05000600)
#define VRAM_A MEM16(0x06000000)
#define VRAM_B MEM16(0x06200000)
#define VRAM_OBJ_A MEM16(0x06400000)
#define VRAM_OBJ_B MEM16(0x06600000)
#define OAM_A MEM16(0x07000000)
#define OAM_B MEM16(0x7000400)
#define VRAM_A_OFFS_0K MEM16(0x06000000)
#define VRAM_A_OFFS_2K MEM16(0x06000800)
#define VRAM_A_OFFS_4K MEM16(0x06001000)
#define VRAM_A_OFFS_6K MEM16(0x06001800)
#define VRAM_A_OFFS_8K MEM16(0x06002000)
#define VRAM_A_OFFS_10K MEM16(0x06002800)
#define VRAM_A_OFFS_12K MEM16(0x06003000)
#define VRAM_A_OFFS_14K MEM16(0x06003800)
#define VRAM_A_OFFS_16K MEM16(0x06004000)
#define VRAM_A_OFFS_18K MEM16(0x06004800)
#define VRAM_A_OFFS_20K MEM16(0x06005000)
#define VRAM_A_OFFS_22K MEM16(0x06005800)
#define VRAM_A_OFFS_24K MEM16(0x06006000)
#define VRAM_A_OFFS_26K MEM16(0x06006800)
#define VRAM_A_OFFS_28K MEM16(0x06007000)
#define VRAM_A_OFFS_30K MEM16(0x06007800)
#define VRAM_A_OFFS_32K MEM16(0x06008000)
#define VRAM_A_OFFS_34K MEM16(0x06008800)
#define VRAM_A_OFFS_36K MEM16(0x06009000)
#define VRAM_A_OFFS_38K MEM16(0x06009800)
#define VRAM_A_OFFS_40K MEM16(0x0600a000)
#define VRAM_A_OFFS_42K MEM16(0x0600a800)
#define VRAM_A_OFFS_44K MEM16(0x0600b000)
#define VRAM_A_OFFS_46K MEM16(0x0600b800)
#define VRAM_A_OFFS_48K MEM16(0x0600c000)
#define VRAM_A_OFFS_50K MEM16(0x0600c800)
#define VRAM_A_OFFS_52K MEM16(0x0600d000)
#define VRAM_A_OFFS_55K MEM16(0x0600d800)
#define VRAM_A_OFFS_56K MEM16(0x0600e000)
#define VRAM_A_OFFS_58K MEM16(0x0600e800)
#define VRAM_A_OFFS_60K MEM16(0x0600f000)
#define VRAM_A_OFFS_62K MEM16(0x0600f800)
#define VRAM_A_OFFS_64K MEM16(0x06010000)
#define VRAM_B_OFFS_0K MEM16(0x06200000)
#define VRAM_B_OFFS_2K MEM16(0x06200800)
#define VRAM_B_OFFS_4K MEM16(0x06201000)
#define VRAM_B_OFFS_6K MEM16(0x06201800)
#define VRAM_B_OFFS_8K MEM16(0x06202000)
#define VRAM_B_OFFS_10K MEM16(0x06202800)
#define VRAM_B_OFFS_12K MEM16(0x06203000)
#define VRAM_B_OFFS_14K MEM16(0x06203800)
#define VRAM_B_OFFS_16K MEM16(0x06204000)
#define VRAM_B_OFFS_18K MEM16(0x06204800)
#define VRAM_B_OFFS_20K MEM16(0x06205000)
#define VRAM_B_OFFS_22K MEM16(0x06205800)
#define VRAM_B_OFFS_24K MEM16(0x06206000)
#define VRAM_B_OFFS_26K MEM16(0x06206800)
#define VRAM_B_OFFS_28K MEM16(0x06207000)
#define VRAM_B_OFFS_30K MEM16(0x06207800)
#define VRAM_B_OFFS_32K MEM16(0x06208000)
#define VRAM_B_OFFS_34K MEM16(0x06208800)
#define VRAM_B_OFFS_36K MEM16(0x06209000)
#define VRAM_B_OFFS_38K MEM16(0x06209800)
#define VRAM_B_OFFS_40K MEM16(0x0620a000)
#define VRAM_B_OFFS_42K MEM16(0x0620a800)
#define VRAM_B_OFFS_44K MEM16(0x0620b000)
#define VRAM_B_OFFS_46K MEM16(0x0620b800)
#define VRAM_B_OFFS_48K MEM16(0x0620c000)
#define VRAM_B_OFFS_50K MEM16(0x0620c800)
#define VRAM_B_OFFS_52K MEM16(0x0620d000)
#define VRAM_B_OFFS_55K MEM16(0x0620d800)
#define VRAM_B_OFFS_56K MEM16(0x0620e000)
#define VRAM_B_OFFS_58K MEM16(0x0620e800)
#define VRAM_B_OFFS_60K MEM16(0x0620f000)
#define VRAM_B_OFFS_62K MEM16(0x0620f800)
#define VRAM_B_OFFS_64K MEM16(0x06210000)
#define VRAM_LCDC_A MEM16(0x6800000)
#define VRAM_LCDC_B MEM16(0x6820000)
#define VRAM_LCDC_C MEM16(0x6840000)
#define VRAM_LCDC_D MEM16(0x6860000)
#define VRAM_LCDC_E MEM16(0x6880000)
#define VRAM_LCDC_F MEM16(0x6890000)
#define VRAM_LCDC_G MEM16(0x6894000)
#define VRAM_LCDC_H MEM16(0x6898000)
#define VRAM_LCDC_I MEM16(0x68a0000)
//
// Video (ARM9)
//
// Display control
#define DISPCNT_A REG32(0x04000000)
#define DISPCNT_B REG32(0x04001000)
#define DISPCNT_MODE_0 (0<<0)
#define DISPCNT_MODE_1 (1<<0)
#define DISPCNT_MODE_2 (2<<0)
#define DISPCNT_MODE_3 (3<<0)
#define DISPCNT_MODE_4 (4<<0)
#define DISPCNT_MODE_5 (5<<0)
#define DISPCNT_MODE_6 (6<<0) // Engine A only
#define DISPCNT_3D (1<<3) // Engine A only
#define DISPCNT_OBJ_MAPPING_2D (0<<4)
#define DISPCNT_OBJ_MAPPING_1D (1<<4)
#define DISPCNT_BMPOBJ_MAPPING_2D_128 (0<<5)
#define DISPCNT_BMPOBJ_MAPPING_2D_256 (1<<5)
#define DISPCNT_BMPOBJ_MAPPING_1D (2<<5)
#define DISPCNT_BLANK (1<<7)
#define DISPCNT_BG0_ON (1<<8)
#define DISPCNT_BG1_ON (1<<9)
#define DISPCNT_BG2_ON (1<<10)
#define DISPCNT_BG3_ON (1<<11)
#define DISPCNT_OBJ_ON (1<<12)
#define DISPCNT_WINDOW_0_ON (1<<13)
#define DISPCNT_WINDOW_1_ON (1<<14)
#define DISPCNT_OBJ_WINDOW_ON (1<<15)
#define DISPCNT_OFF (0<<16)
#define DISPCNT_ON (1<<16)
#define DISPCNT_VRAM (2<<16) // Engine A only
#define DISPCNT_FIFO (3<<16) // Engine A only
#define DISPCNT_VRAM_BLOCK_0 (0<<18)
#define DISPCNT_VRAM_BLOCK_1 (1<<18)
#define DISPCNT_VRAM_BLOCK_2 (2<<18)
#define DISPCNT_VRAM_BLOCK_3 (3<<18)
#define DISPCNT_OBJ_1D_SIZE_32K (0<<20)
#define DISPCNT_OBJ_1D_SIZE_64K (1<<20)
#define DISPCNT_OBJ_1D_SIZE_128K (2<<20)
#define DISPCNT_OBJ_1D_SIZE_256K (3<<20)
#define DISPCNT_BMPOBJ_1D_SIZE_128K (0<<22)
#define DISPCNT_BMPOBJ_1D_SIZE_256K (1<<22)
#define DISPCNT_OBJ_HBLANK (1<<23)
#define DISPCNT_CHAR_BASE(n) (((n)&7)<<24)
#define DISPCNT_CHAR_BASE_0K DISPCNT_CHAR_BASE(0)
#define DISPCNT_CHAR_BASE_64K DISPCNT_CHAR_BASE(1)
#define DISPCNT_CHAR_BASE_128K DISPCNT_CHAR_BASE(2)
#define DISPCNT_CHAR_BASE_192K DISPCNT_CHAR_BASE(3)
#define DISPCNT_CHAR_BASE_256K DISPCNT_CHAR_BASE(4)
#define DISPCNT_CHAR_BASE_320K DISPCNT_CHAR_BASE(5)
#define DISPCNT_CHAR_BASE_384K DISPCNT_CHAR_BASE(6)
#define DISPCNT_CHAR_BASE_448K DISPCNT_CHAR_BASE(7)
#define DISPCNT_SCREEN_BASE(n) (((n)&7)<<27)
#define DISPCNT_SCREEN_BASE_0K DISPCNT_SCREEN_BASE(0)
#define DISPCNT_SCREEN_BASE_64K DISPCNT_SCREEN_BASE(1)
#define DISPCNT_SCREEN_BASE_128K DISPCNT_SCREEN_BASE(2)
#define DISPCNT_SCREEN_BASE_192K DISPCNT_SCREEN_BASE(3)
#define DISPCNT_SCREEN_BASE_256K DISPCNT_SCREEN_BASE(4)
#define DISPCNT_SCREEN_BASE_320K DISPCNT_SCREEN_BASE(5)
#define DISPCNT_SCREEN_BASE_384K DISPCNT_SCREEN_BASE(6)
#define DISPCNT_SCREEN_BASE_448K DISPCNT_SCREEN_BASE(7)
#define DISPCNT_OBJ_EXT_PALETTE (1<<31)
#define DISPCNT_BG_EXT_PALETTE (1<<30)
// Interrupts and status
#define DISPSTAT_A REG16(0x04000004)
#define DISPSTAT_B REG16(0x04001004)
#define VCOUNT_A REG16(0x04000006)
#define VCOUNT_B REG16(0x04001006)
#define DISPSTAT_VBLANK (1<<0)
#define DISPSTAT_HBLANK (1<<1)
#define DISPSTAT_VCOUNT (1<<2)
#define DISPSTAT_VBLANK_IRQ (1<<3)
#define DISPSTAT_HBLANK_IRQ (1<<4)
#define DISPSTAT_VCOUNT_IRQ (1<<5)
// BG control
#define BG0CNT_A REG16(0x04000008)
#define BG1CNT_A REG16(0x0400000a)
#define BG2CNT_A REG16(0x0400000c)
#define BG3CNT_A REG16(0x0400000e)
#define BG0CNT_B REG16(0x04001008)
#define BG1CNT_B REG16(0x0400100a)
#define BG2CNT_B REG16(0x0400100c)
#define BG3CNT_B REG16(0x0400100e)
#define BGxCNT_PRIORITY_0 (0<<0)
#define BGxCNT_PRIORITY_1 (1<<0)
#define BGxCNT_PRIORITY_2 (2<<0)
#define BGxCNT_PRIORITY_3 (3<<0)
#define BGxCNT_CHAR_BASE(n) (((n)&0xf)<<2)
#define BGxCNT_CHAR_BASE_0K BGxCNT_CHAR_BASE(0)
#define BGxCNT_CHAR_BASE_16K BGxCNT_CHAR_BASE(1)
#define BGxCNT_CHAR_BASE_32K BGxCNT_CHAR_BASE(2)
#define BGxCNT_CHAR_BASE_48K BGxCNT_CHAR_BASE(3)
#define BGxCNT_CHAR_BASE_64K BGxCNT_CHAR_BASE(4)
#define BGxCNT_CHAR_BASE_80K BGxCNT_CHAR_BASE(5)
#define BGxCNT_CHAR_BASE_96K BGxCNT_CHAR_BASE(6)
#define BGxCNT_CHAR_BASE_112K BGxCNT_CHAR_BASE(7)
#define BGxCNT_CHAR_BASE_128K BGxCNT_CHAR_BASE(8)
#define BGxCNT_CHAR_BASE_144K BGxCNT_CHAR_BASE(9)
#define BGxCNT_CHAR_BASE_160K BGxCNT_CHAR_BASE(10)
#define BGxCNT_CHAR_BASE_176K BGxCNT_CHAR_BASE(11)
#define BGxCNT_CHAR_BASE_192K BGxCNT_CHAR_BASE(12)
#define BGxCNT_CHAR_BASE_208K BGxCNT_CHAR_BASE(13)
#define BGxCNT_CHAR_BASE_224K BGxCNT_CHAR_BASE(14)
#define BGxCNT_CHAR_BASE_240K BGxCNT_CHAR_BASE(15)
#define BGxCNT_MOSAIC (1<<6)
#define BGxCNT_TEXT_16_COLOURS (0<<7)
#define BGxCNT_TEXT_256_COLOURS (1<<7)
#define BGxCNT_EXTENDED_TILES 0x00
#define BGxCNT_EXTENDED_BITMAP_8 0x80
#define BGxCNT_EXTENDED_BITMAP_16 0x84
#define BGxCNT_SCREEN_BASE(n) (((n)&0x1f)<<8)
#define BGxCNT_TILE_BASE_0K BGxCNT_SCREEN_BASE(0)
#define BGxCNT_TILE_BASE_2K BGxCNT_SCREEN_BASE(1)
#define BGxCNT_TILE_BASE_4K BGxCNT_SCREEN_BASE(2)
#define BGxCNT_TILE_BASE_6K BGxCNT_SCREEN_BASE(3)
#define BGxCNT_TILE_BASE_8K BGxCNT_SCREEN_BASE(4)
#define BGxCNT_TILE_BASE_10K BGxCNT_SCREEN_BASE(5)
#define BGxCNT_TILE_BASE_12K BGxCNT_SCREEN_BASE(6)
#define BGxCNT_TILE_BASE_14K BGxCNT_SCREEN_BASE(7)
#define BGxCNT_TILE_BASE_16K BGxCNT_SCREEN_BASE(8)
#define BGxCNT_TILE_BASE_18K BGxCNT_SCREEN_BASE(9)
#define BGxCNT_TILE_BASE_20K BGxCNT_SCREEN_BASE(10)
#define BGxCNT_TILE_BASE_22K BGxCNT_SCREEN_BASE(11)
#define BGxCNT_TILE_BASE_24K BGxCNT_SCREEN_BASE(12)
#define BGxCNT_TILE_BASE_26K BGxCNT_SCREEN_BASE(13)
#define BGxCNT_TILE_BASE_28K BGxCNT_SCREEN_BASE(14)
#define BGxCNT_TILE_BASE_30K BGxCNT_SCREEN_BASE(15)
#define BGxCNT_TILE_BASE_32K BGxCNT_SCREEN_BASE(16)
#define BGxCNT_TILE_BASE_34K BGxCNT_SCREEN_BASE(17)
#define BGxCNT_TILE_BASE_36K BGxCNT_SCREEN_BASE(18)
#define BGxCNT_TILE_BASE_38K BGxCNT_SCREEN_BASE(19)
#define BGxCNT_TILE_BASE_40K BGxCNT_SCREEN_BASE(20)
#define BGxCNT_TILE_BASE_42K BGxCNT_SCREEN_BASE(21)
#define BGxCNT_TILE_BASE_44K BGxCNT_SCREEN_BASE(22)
#define BGxCNT_TILE_BASE_46K BGxCNT_SCREEN_BASE(23)
#define BGxCNT_TILE_BASE_48K BGxCNT_SCREEN_BASE(24)
#define BGxCNT_TILE_BASE_50K BGxCNT_SCREEN_BASE(25)
#define BGxCNT_TILE_BASE_52K BGxCNT_SCREEN_BASE(26)
#define BGxCNT_TILE_BASE_54K BGxCNT_SCREEN_BASE(27)
#define BGxCNT_TILE_BASE_56K BGxCNT_SCREEN_BASE(28)
#define BGxCNT_TILE_BASE_58K BGxCNT_SCREEN_BASE(29)
#define BGxCNT_TILE_BASE_60K BGxCNT_SCREEN_BASE(30)
#define BGxCNT_TILE_BASE_62K BGxCNT_SCREEN_BASE(31)
#define BGxCNT_BITMAP_BASE_0K BGxCNT_SCREEN_BASE(0)
#define BGxCNT_BITMAP_BASE_16K BGxCNT_SCREEN_BASE(1)
#define BGxCNT_BITMAP_BASE_32K BGxCNT_SCREEN_BASE(2)
#define BGxCNT_BITMAP_BASE_48K BGxCNT_SCREEN_BASE(3)
#define BGxCNT_BITMAP_BASE_64K BGxCNT_SCREEN_BASE(4)
#define BGxCNT_BITMAP_BASE_80K BGxCNT_SCREEN_BASE(5)
#define BGxCNT_BITMAP_BASE_96K BGxCNT_SCREEN_BASE(6)
#define BGxCNT_BITMAP_BASE_112K BGxCNT_SCREEN_BASE(7)
#define BGxCNT_BITMAP_BASE_128K BGxCNT_SCREEN_BASE(8)
#define BGxCNT_BITMAP_BASE_144K BGxCNT_SCREEN_BASE(9)
#define BGxCNT_BITMAP_BASE_160K BGxCNT_SCREEN_BASE(10)
#define BGxCNT_BITMAP_BASE_176K BGxCNT_SCREEN_BASE(11)
#define BGxCNT_BITMAP_BASE_192K BGxCNT_SCREEN_BASE(12)
#define BGxCNT_BITMAP_BASE_208K BGxCNT_SCREEN_BASE(13)
#define BGxCNT_BITMAP_BASE_224K BGxCNT_SCREEN_BASE(14)
#define BGxCNT_BITMAP_BASE_240K BGxCNT_SCREEN_BASE(15)
#define BGxCNT_BITMAP_BASE_256K BGxCNT_SCREEN_BASE(16)
#define BGxCNT_BITMAP_BASE_272K BGxCNT_SCREEN_BASE(17)
#define BGxCNT_BITMAP_BASE_288K BGxCNT_SCREEN_BASE(18)
#define BGxCNT_BITMAP_BASE_304K BGxCNT_SCREEN_BASE(19)
#define BGxCNT_BITMAP_BASE_320K BGxCNT_SCREEN_BASE(20)
#define BGxCNT_BITMAP_BASE_336K BGxCNT_SCREEN_BASE(21)
#define BGxCNT_BITMAP_BASE_352K BGxCNT_SCREEN_BASE(22)
#define BGxCNT_BITMAP_BASE_368K BGxCNT_SCREEN_BASE(23)
#define BGxCNT_BITMAP_BASE_384K BGxCNT_SCREEN_BASE(24)
#define BGxCNT_BITMAP_BASE_400K BGxCNT_SCREEN_BASE(25)
#define BGxCNT_BITMAP_BASE_416K BGxCNT_SCREEN_BASE(26)
#define BGxCNT_BITMAP_BASE_432K BGxCNT_SCREEN_BASE(27)
#define BGxCNT_BITMAP_BASE_448K BGxCNT_SCREEN_BASE(28)
#define BGxCNT_BITMAP_BASE_464K BGxCNT_SCREEN_BASE(29)
#define BGxCNT_BITMAP_BASE_480K BGxCNT_SCREEN_BASE(30)
#define BGxCNT_BITMAP_BASE_496K BGxCNT_SCREEN_BASE(31)
#define BGxCNT_OVERFLOW_TRANSPARENT (0<<13)
#define BGxCNT_OVERFLOW_WRAP (1<<13)
#define BGxCNT_ALTERNATE_PALETTE_SLOT (1<<13) // BG0 and BG1 only
#define BGxCNT_TEXT_SIZE_256x256 (0<<14)
#define BGxCNT_TEXT_SIZE_512x256 (1<<14)
#define BGxCNT_TEXT_SIZE_256x512 (2<<14)
#define BGxCNT_TEXT_SIZE_512x512 (3<<14)
#define BGxCNT_AFFINE_SIZE_128x128 (0<<14)
#define BGxCNT_AFFINE_SIZE_256x256 (1<<14)
#define BGxCNT_AFFINE_SIZE_512x512 (2<<14)
#define BGxCNT_AFFINE_SIZE_1024x1024 (3<<14)
#define BGxCNT_BITMAP_SIZE_128x128 (0<<14)
#define BGxCNT_BITMAP_SIZE_256x256 (1<<14)
#define BGxCNT_BITMAP_SIZE_512x256 (2<<14)
#define BGxCNT_BITMAP_SIZE_512x512 (3<<14)
#define BGxCNT_LARGE_SIZE_512x1024 (0<<14)
#define BGxCNT_LARGE_SIZE_1024x512 (1<<14)
// BG scrolling
#define BG0HOFS_A REG16(0x04000010)
#define BG0VOFS_A REG16(0x04000012)
#define BG1HOFS_A REG16(0x04000014)
#define BG1VOFS_A REG16(0x04000016)
#define BG2HOFS_A REG16(0x04000018)
#define BG2VOFS_A REG16(0x0400001a)
#define BG3HOFS_A REG16(0x0400001c)
#define BG3VOFS_A REG16(0x0400001e)
#define BG0HOFS_B REG16(0x04001010)
#define BG0VOFS_B REG16(0x04001012)
#define BG1HOFS_B REG16(0x04001014)
#define BG1VOFS_B REG16(0x04001016)
#define BG2HOFS_B REG16(0x04001018)
#define BG2VOFS_B REG16(0x0400101a)
#define BG3HOFS_B REG16(0x0400101c)
#define BG3VOFS_B REG16(0x0400101e)
// BG rotation and scaling
#define BG2PA_A REG16(0x04000020)
#define BG2PB_A REG16(0x04000022)
#define BG2PC_A REG16(0x04000024)
#define BG2PD_A REG16(0x04000026)
#define BG2X_L_A REG16(0x04000028)
#define BG2X_H_A REG16(0x0400002a)
#define BG2Y_L_A REG16(0x0400002c)
#define BG2Y_H_A REG16(0x0400002e)
#define BG2X_A REG32(0x04000028)
#define BG2Y_A REG32(0x0400002C)
#define BG2PA_B REG16(0x04001020)
#define BG2PB_B REG16(0x04001022)
#define BG2PC_B REG16(0x04001024)
#define BG2PD_B REG16(0x04001026)
#define BG2X_L_B REG16(0x04001028)
#define BG2X_H_B REG16(0x0400102a)
#define BG2Y_L_B REG16(0x0400102c)
#define BG2Y_H_B REG16(0x0400102e)
#define BG2X_B REG32(0x04001028)
#define BG2Y_B REG32(0x0400102C)
#define BG3PA_A REG16(0x04000030)
#define BG3PB_A REG16(0x04000032)
#define BG3PC_A REG16(0x04000034)
#define BG3PD_A REG16(0x04000036)
#define BG3X_L_A REG16(0x04000038)
#define BG3X_H_A REG16(0x0400003a)
#define BG3Y_L_A REG16(0x0400003c)
#define BG3Y_H_A REG16(0x0400003e)
#define BG3X_A REG32(0x04000038)
#define BG3Y_A REG32(0x0400003C)
#define BG3PA_B REG16(0x04001030)
#define BG3PB_B REG16(0x04001032)
#define BG3PC_B REG16(0x04001034)
#define BG3PD_B REG16(0x04001036)
#define BG3X_L_B REG16(0x04001038)
#define BG3X_H_B REG16(0x0400103a)
#define BG3Y_L_B REG16(0x0400103c)
#define BG3Y_H_B REG16(0x0400103e)
#define BG3X_B REG32(0x04001038)
#define BG3Y_B REG32(0x0400103C)
//
// Timers
//
#define TM0CNT_L REG16(0x4000100)
#define TM0CNT_H REG16(0x4000102)
#define TM1CNT_L REG16(0x4000104)
#define TM1CNT_H REG16(0x4000106)
#define TM2CNT_L REG16(0x4000108)
#define TM2CNT_H REG16(0x400010a)
#define TM3CNT_L REG16(0x400010c)
#define TM3CNT_H REG16(0x400010e)
#define TMxCNT_H_DIV_1 0
#define TMxCNT_H_DIV_64 1
#define TMxCNT_H_DIV_256 2
#define TMxCNT_H_DIV_1024 3
#define TMxCNT_H_COUNT_UP (1<<2)
#define TMxCNT_H_IRQ_ENABLE (1<<6)
#define TMxCNT_H_START (1<<7)
//
// Memory control
//
#define VRAMCNT_A REG8(0x4000240)
#define VRAMCNT_B REG8(0x4000241)
#define VRAMCNT_C REG8(0x4000242)
#define VRAMCNT_D REG8(0x4000243)
#define VRAMCNT_E REG8(0x4000244)
#define VRAMCNT_F REG8(0x4000245)
#define VRAMCNT_G REG8(0x4000246)
#define VRAMCNT_H REG8(0x4000248)
#define VRAMCNT_I REG8(0x4000249)
#define VRAMCNT_OFFSET_0 (0<<3)
#define VRAMCNT_OFFSET_1 (1<<3)
#define VRAMCNT_OFFSET_2 (2<<3)
#define VRAMCNT_OFFSET_3 (3<<3)
#define VRAMCNT_DISABLE (0<<7)
#define VRAMCNT_ENABLE (1<<7)
#define VRAMCNT_A_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_A_BG_VRAM_A (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_A_BG_VRAM_A_OFFS_0K (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_A_BG_VRAM_A_OFFS_128K (1|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_A_BG_VRAM_A_OFFS_256K (1|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_A_BG_VRAM_A_OFFS_384K (1|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_A_OBJ_VRAM_A (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_A_OBJ_VRAM_A_OFFS_0K (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_A_OBJ_VRAM_A_OFFS_128K (2|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_A_TEXTURE (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_A_TEXTURE_OFFS_0K (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_A_TEXTURE_OFFS_128K (3|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_A_TEXTURE_OFFS_256K (3|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_A_TEXTURE_OFFS_384K (3|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_B_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_B_BG_VRAM_A (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_B_BG_VRAM_A_OFFS_0K (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_B_BG_VRAM_A_OFFS_128K (1|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_B_BG_VRAM_A_OFFS_256K (1|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_B_BG_VRAM_A_OFFS_384K (1|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_B_OBJ_VRAM_A (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_B_OBJ_VRAM_A_OFFS_0K (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_B_OBJ_VRAM_A_OFFS_128K (2|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_B_TEXTURE (3|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_B_TEXTURE_OFFS_0K (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_B_TEXTURE_OFFS_128K (3|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_B_TEXTURE_OFFS_256K (3|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_B_TEXTURE_OFFS_384K (3|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_C_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_C_BG_VRAM_A (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_C_BG_VRAM_A_OFFS_0K (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_C_BG_VRAM_A_OFFS_128K (1|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_C_BG_VRAM_A_OFFS_256K (1|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_C_BG_VRAM_A_OFFS_384K (1|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_C_ARM7 (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_C_ARM7_OFFS_0K (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_C_ARM7_OFFS_128K (2|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_C_TEXTURE (3|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_C_TEXTURE_OFFS_0K (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_C_TEXTURE_OFFS_128K (3|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_C_TEXTURE_OFFS_256K (3|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_C_TEXTURE_OFFS_384K (3|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_C_BG_VRAM_B (4|VRAMCNT_ENABLE)
#define VRAMCNT_D_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_D_BG_VRAM_A (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_D_BG_VRAM_A_OFFS_0K (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_D_BG_VRAM_A_OFFS_128K (1|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_D_BG_VRAM_A_OFFS_256K (1|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_D_BG_VRAM_A_OFFS_384K (1|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_D_ARM7 (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_D_ARM7_OFFS_0K (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_D_ARM7_OFFS_128K (2|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_D_TEXTURE (3|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_D_TEXTURE_OFFS_0K (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_D_TEXTURE_OFFS_128K (3|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_D_TEXTURE_OFFS_256K (3|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_D_TEXTURE_OFFS_384K (3|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_D_OBJ_VRAM_B (4|VRAMCNT_ENABLE)
#define VRAMCNT_E_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_E_BG_VRAM_A (1|VRAMCNT_ENABLE)
#define VRAMCNT_E_OBJ_VRAM_A (2|VRAMCNT_ENABLE)
#define VRAMCNT_E_TEXTURE_PALETTE (3|VRAMCNT_ENABLE)
#define VRAMCNT_E_BG_EXT_PALETTE_A (4|VRAMCNT_ENABLE)
#define VRAMCNT_F_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_VRAM_A (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_VRAM_A_OFFS_0K (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_VRAM_A_OFFS_16K (1|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_VRAM_A_OFFS_64K (1|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_VRAM_A_OFFS_80K (1|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_F_OBJ_VRAM_A (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_OBJ_VRAM_A_OFFS_0K (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_OBJ_VRAM_A_OFFS_16K (2|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_F_OBJ_VRAM_A_OFFS_64K (2|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_F_OBJ_VRAM_A_OFFS_80K (2|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_F_TEXTURE_PALETTE (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_TEXTURE_PALETTE_SLOT_0 (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_TEXTURE_PALETTE_SLOT_1 (3|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_F_TEXTURE_PALETTE_SLOT_4 (3|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_F_TEXTURE_PALETTE_SLOT_5 (3|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_EXT_PALETTE_A (4|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_EXT_PALETTE_A_SLOTS_0_1 (4|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_F_BG_EXT_PALETTE_A_SLOTS_2_3 (4|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_F_OBJ_EXT_PALETTE_A (5|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_VRAM_A (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_VRAM_A_OFFS_0K (1|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_VRAM_A_OFFS_16K (1|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_VRAM_A_OFFS_64K (1|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_VRAM_A_OFFS_80K (1|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_G_OBJ_VRAM_A (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_OBJ_VRAM_A_OFFS_0K (2|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_OBJ_VRAM_A_OFFS_16K (2|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_G_OBJ_VRAM_A_OFFS_64K (2|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_G_OBJ_VRAM_A_OFFS_80K (2|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_G_TEXTURE_PALETTE (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_TEXTURE_PALETTE_SLOT_0 (3|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_TEXTURE_PALETTE_SLOT_1 (3|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_G_TEXTURE_PALETTE_SLOT_4 (3|VRAMCNT_OFFSET_2|VRAMCNT_ENABLE)
#define VRAMCNT_G_TEXTURE_PALETTE_SLOT_5 (3|VRAMCNT_OFFSET_3|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_EXT_PALETTE_A (4|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_EXT_PALETTE_A_SLOTS_0_1 (4|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_G_BG_EXT_PALETTE_A_SLOTS_2_3 (4|VRAMCNT_OFFSET_1|VRAMCNT_ENABLE)
#define VRAMCNT_G_OBJ_EXT_PALETTE_A (5|VRAMCNT_OFFSET_0|VRAMCNT_ENABLE)
#define VRAMCNT_H_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_H_BG_VRAM_B (1|VRAMCNT_ENABLE)
#define VRAMCNT_H_BG_EXT_PALETTE_B (2|VRAMCNT_ENABLE)
#define VRAMCNT_I_LCDC (0|VRAMCNT_ENABLE)
#define VRAMCNT_I_BG_VRAM_B_OFFS_32K (1|VRAMCNT_ENABLE)
#define VRAMCNT_I_OBJ_VRAM_B (2|VRAMCNT_ENABLE)
#define VRAMCNT_I_OBJ_EXT_PALETTE_B (3|VRAMCNT_ENABLE)
//
// Sound (ARM7)
//
#define SOUNDxCNT(n) REG32(0x04000400+((n)<<4))
#define SOUNDxSAD(n) REGPTR(0x04000404+((n)<<4))
#define SOUNDxTMR(n) REG16(0x04000408+((n)<<4))
#define SOUNDxPNT(n) REG16(0x0400040a+((n)<<4))
#define SOUNDxLEN(n) REG32(0x0400040c+((n)<<4))
#define SOUND0CNT SOUNDxCNT(0)
#define SOUND0SAD SOUNDxSAD(0)
#define SOUND0TMR SOUNDxTMR(0)
#define SOUND0PNT SOUNDxPNT(0)
#define SOUND0LEN SOUNDxLEN(0)
#define SOUND1CNT SOUNDxCNT(1)
#define SOUND1SAD SOUNDxSAD(1)
#define SOUND1TMR SOUNDxTMR(1)
#define SOUND1PNT SOUNDxPNT(1)
#define SOUND1LEN SOUNDxLEN(1)
#define SOUND14CNT SOUNDxCNT(14)
#define SOUND14SAD SOUNDxSAD(14)
#define SOUND14TMR SOUNDxTMR(14)
#define SOUND14PNT SOUNDxPNT(14)
#define SOUND14LEN SOUNDxLEN(14)
#define SOUND15CNT SOUNDxCNT(15)
#define SOUND15SAD SOUNDxSAD(15)
#define SOUND15TMR SOUNDxTMR(15)
#define SOUND15PNT SOUNDxPNT(15)
#define SOUND15LEN SOUNDxLEN(15)
#define SOUNDxCNT_VOLUME(n) (n)
#define SOUNDxCNT_VOLUME_MAX 127
#define SOUNDxCNT_VOLUME_DIV_1 (0<<8)
#define SOUNDxCNT_VOLUME_DIV_2 (1<<8)
#define SOUNDxCNT_VOLUME_DIV_4 (2<<8)
#define SOUNDxCNT_VOLUME_DIV_16 (3<<8)
#define SOUNDxCNT_HOLD (1<<15)
#define SOUNDxCNT_PAN(n) ((n)<<16)
#define SOUNDxCNT_PAN_LEFT (0<<16)
#define SOUNDxCNT_PAN_MID (64<<16)
#define SOUNDxCNT_PAN_RIGHT (127<<16)
#define SOUNDxCNT_DUTY(n) ((n)<<23)
#define SOUNDxCNT_MANUAL (0<<27)
#define SOUNDxCNT_LOOP (1<<27)
#define SOUNDxCNT_ONESHOT (2<<27)
#define SOUNDxCNT_PCM8 (0<<29)
#define SOUNDxCNT_PCM16 (1<<29)
#define SOUNDxCNT_ADPCM (2<<29)
#define SOUNDxCNT_PSG (3<<29)
#define SOUNDxCNT_START (1<<31)
//#define SOUNDxTMR_FREQ(n) (-0x1000000/(n))
#define SOUNDxTMR_FREQ(n) (-3513982/(2*(n)))
#define SOUNDCNT REG32(0x04000500)
#define SOUNDBIAS REG32(0x04000500)
#define SOUNDCNT_VOLUME(n) (n)
#define SOUNDCNT_VOLUME_MAX 127
#define SOUNDCNT_LEFT_FROM_LEFT (0<<8)
#define SOUNDCNT_LEFT_FROM_CH1 (1<<8)
#define SOUNDCNT_LEFT_FROM_CH3 (2<<8)
#define SOUNDCNT_LEFT_FROM_CH1_CH3 (3<<8)
#define SOUNDCNT_RIGHT_FROM_RIGHT (0<<10)
#define SOUNDCNT_RIGHT_FROM_CH1 (1<<10)
#define SOUNDCNT_RIGHT_FROM_CH3 (2<<10)
#define SOUNDCNT_RIGHT_FROM_CH1_CH3 (3<<10)
#define SOUNDCNT_NO_CH1_TO_MIXER (1<<12)
#define SOUNDCNT_NO_CH3_TO_MIXER (1<<13)
#define SOUNDCNT_ENABLE (1<<15)
#define SOUNDBIAS_NORMAL 0x200
//
// OAM attributes
//
#define OBJ_0_Y(y) ((y)&0xff)
#define OBJ_0_ROTSCALE (1<<8)
#define OBJ_0_DISABLE (2<<8)
#define OBJ_0_ROTSCALE_DOUBLE (3<<8)
#define OBJ_0_TRANSPARENT (1<<10)
#define OBJ_0_WINDOW (2<<10)
#define OBJ_0_BITMAP (3<<10)
#define OBJ_0_MOSAIC (1<<12)
#define OBJ_0_16_COLOURS (0<<13)
#define OBJ_0_256_COLOURS (1<<13)
#define OBJ_0_SQUARE (0<<14)
#define OBJ_0_HORIZONTAL (1<<14)
#define OBJ_0_VERTICAL (2<<14)
#define OBJ_0_SIZE_8x8 OBJ_0_SQUARE
#define OBJ_0_SIZE_16x16 OBJ_0_SQUARE
#define OBJ_0_SIZE_32x32 OBJ_0_SQUARE
#define OBJ_0_SIZE_64x64 OBJ_0_SQUARE
#define OBJ_0_SIZE_16x8 OBJ_0_HORIZONTAL
#define OBJ_0_SIZE_32x8 OBJ_0_HORIZONTAL
#define OBJ_0_SIZE_32x16 OBJ_0_HORIZONTAL
#define OBJ_0_SIZE_64x32 OBJ_0_HORIZONTAL
#define OBJ_0_SIZE_8x16 OBJ_0_VERTICAL
#define OBJ_0_SIZE_8x32 OBJ_0_VERTICAL
#define OBJ_0_SIZE_16x32 OBJ_0_VERTICAL
#define OBJ_0_SIZE_32x64 OBJ_0_VERTICAL
#define OBJ_1_X(x) ((x)&0x1ff)
#define OBJ_1_ROTSCALE_PARAMS(n) (((n)&0x1f)<<9)
#define OBJ_1_HORIZ_FLIP (1<<12)
#define OBJ_1_VERT_FLIP (1<<13)
#define OBJ_1_SIZE_0 (0<<14)
#define OBJ_1_SIZE_1 (1<<14)
#define OBJ_1_SIZE_2 (2<<14)
#define OBJ_1_SIZE_3 (3<<14)
#define OBJ_1_SIZE_8x8 OBJ_1_SIZE_0
#define OBJ_1_SIZE_16x16 OBJ_1_SIZE_1
#define OBJ_1_SIZE_32x32 OBJ_1_SIZE_2
#define OBJ_1_SIZE_64x64 OBJ_1_SIZE_3
#define OBJ_1_SIZE_16x8 OBJ_1_SIZE_0
#define OBJ_1_SIZE_32x8 OBJ_1_SIZE_1
#define OBJ_1_SIZE_32x16 OBJ_1_SIZE_2
#define OBJ_1_SIZE_64x32 OBJ_1_SIZE_3
#define OBJ_1_SIZE_8x16 OBJ_1_SIZE_0
#define OBJ_1_SIZE_8x32 OBJ_1_SIZE_1
#define OBJ_1_SIZE_16x32 OBJ_1_SIZE_2
#define OBJ_1_SIZE_32x64 OBJ_1_SIZE_3
#define OBJ_2_CHAR(x) ((x)&0x3ff)
#define OBJ_2_PRIORITY_0 (0<<10)
#define OBJ_2_PRIORITY_1 (1<<10)
#define OBJ_2_PRIORITY_2 (2<<10)
#define OBJ_2_PRIORITY_3 (3<<10)
#define OBJ_2_PALETTE(n) (((n)&0x0f)<<12)
#define OBJ_2_ALPHA(n) OBJ_2_PALETTE(n)
#endif