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