0be7275f2e84a9516b77499a1c513c9e4b78db40
[lugburz] / src / amiga / main.c
1 #include <string.h>
2 #include "amigalib.h"
3 #include "hwregs.h"
4 #include "copper.h"
5 #include "gfx.h"
6 #include "game.h"
7 #include "serial.h"
8 #include "mem.h"
9
10 static uint32_t coplist[128];
11
12 int main(void)
13 {
14         int i;
15
16         REG_INTENA = SETBITS(INTEN_VERTB | INTEN_MASTER);
17         REG_DMACON = CLRBITS(DMA_ALL);
18
19         ser_init(38400);
20         ser_print("lugburz amiga starting up...\n");
21
22         alib_init();
23
24         init_mem();
25
26         init_gfx();
27
28         REG_COLOR0 = 0x111;
29         REG_COLOR1 = 0x23c;
30         REG_COLOR2 = 0xc32;
31         REG_COLOR3 = 0x22c;
32         REG_COLOR4 = 0xcc2;
33
34         wait_vblank();
35
36         init_copper(coplist, 32, COPPER_SINGLE);
37         for(i=0; i<NBPL; i++) {
38                 uint32_t addr = (intptr_t)bplptr[i];
39                 int reg = REGN_BPL1PTH + i * 4;
40                 add_copper(COPPER_MOVE(reg, addr >> 16));
41                 add_copper(COPPER_MOVE(reg + 2, addr));
42         }
43         add_copper(COPPER_VWAIT(50));
44         add_copper(COPPER_MOVE(REGN_COLOR0, 0xf00));
45         add_copper(COPPER_VWAIT(60));
46         add_copper(COPPER_MOVE(REGN_COLOR0, 0x111));
47         *copperlist_end = COPPER_END;
48
49         game_init();
50
51         wait_vblank();
52         REG_DMACON = SETBITS(DMA_BPL | DMA_COPPER | DMA_MASTER);
53
54         for(;;) {
55                 wait_vblank();
56                 game_draw();
57         }
58         return 0;
59 }