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