amiga_boottest

view src/main.c @ 2:58ebd84822e7

it works
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 22 Feb 2018 12:44:20 +0200
parents 48093e4bd99a
children 555b986cc420
line source
1 #include "hwregs.h"
2 #include "intr.h"
3 #include "copper.h"
5 #define BPLSZ (320 / 8 * 256)
6 static unsigned char fb0[BPLSZ];
8 extern uint16_t dbgval;
10 #define wait_vpos(x) \
11 asm volatile ( \
12 "0: move.l 0xdff004, %%d0\n\t" \
13 "and.l #0x1ff00, %%d0\n\t" \
14 "cmp.l %0, %%d0\n\t" \
15 "bne 0b\n\t" \
16 :: "i"((x) << 8) : "%d0")
18 #define wait_vblank() wait_vpos(300)
19 #define wait_scanline(x) wait_vpos((x) + 0x2c)
21 #define clear_bpl(p) \
22 asm volatile ( \
23 "move.l %0, %%a0\n\t" \
24 "move.l %1, %%d0\n\t" \
25 "0: clr.l (%%a0)+\n\t" \
26 "dbra %%d0, 0b\n\t" \
27 :: "a"(p), "i"(BPLSZ / 4 - 1) \
28 : "a0", "d0")
30 static uint32_t coplist[] = {
31 COPPER_MOVE(REGN_BPL1PTH, 0),
32 COPPER_MOVE(REGN_BPL1PTL, 0),
33 COPPER_VWAIT(50),
34 COPPER_MOVE(REGN_COLOR0, 0x00a),
35 COPPER_VWAIT(60),
36 COPPER_MOVE(REGN_COLOR0, 0x008),
37 COPPER_END
38 };
40 int main(void)
41 {
42 REG_INTENA = SETBITS(INTEN_VERTB | INTEN_MASTER);
44 REG_DMACON = CLRBITS(DMA_ALL);
45 REG_BPLCON0 = BPLCON0_COUNT(1) | BPLCON0_COLOR;
46 REG_BPLCON1 = 0;
47 REG_DIWSTART = 0x2981;
48 REG_DIWSTOP = 0x29c1;
49 REG_DDFSTART = 0x38;
50 REG_DDFSTOP = 0xd0;
52 REG_COLOR0 = 0x008;
53 REG_COLOR1 = 0xaaa;
55 wait_vblank();
56 coplist[0] = COPPER_MOVE(REGN_BPL1PTH, (uint32_t)fb0 >> 16);
57 coplist[1] = COPPER_MOVE(REGN_BPL1PTL, (uint32_t)fb0);
58 REG32_COP1LC = (uint32_t)coplist;
59 REG_COPJMP1 = 0;
61 fb0[128 * 320 / 8 + 160 / 8] = 8;
63 REG_DMACON = SETBITS(DMA_BPL | DMA_COPPER | DMA_MASTER);
65 for(;;) {
66 wait_vblank();
67 }
69 return 0;
70 }